diff options
author | Wim <wim@42.be> | 2016-08-14 22:53:09 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2016-08-14 22:54:57 +0200 |
commit | a997ae29ad5297a85ef1e303ec36aaab9e163408 (patch) | |
tree | c9086e0575d9364fe3e1d706489e1ad24c2c0ff8 /matterclient | |
parent | ff9479670070c0f1de4cf66622df7b69736dd22a (diff) | |
download | matterbridge-msglm-a997ae29ad5297a85ef1e303ec36aaab9e163408.tar.gz matterbridge-msglm-a997ae29ad5297a85ef1e303ec36aaab9e163408.tar.bz2 matterbridge-msglm-a997ae29ad5297a85ef1e303ec36aaab9e163408.zip |
Add StatusLoop(), keeps connection alive
Diffstat (limited to 'matterclient')
-rw-r--r-- | matterclient/matterclient.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index a1efa957..75e67c5c 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -534,6 +534,30 @@ func (m *MMClient) GetUser(userId string) *model.User { return m.Users[userId] } +func (m *MMClient) GetStatuses() error { + _, err := m.Client.GetStatuses([]string{m.User.Id}) + if err != nil { + return errors.New(err.DetailedError) + } + return nil +} + +func (m *MMClient) StatusLoop() { + for { + if m.WsQuit { + return + } + if m.WsConnected { + err := m.GetStatuses() + if err != nil { + m.Logout() + m.Login() + } + } + time.Sleep(time.Second * 30) + } +} + // initialize user and teams func (m *MMClient) initUser() error { m.Lock() |