mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-12-25 04:55:41 +00:00
Add StatusLoop(), keeps connection alive
This commit is contained in:
parent
ff94796700
commit
a997ae29ad
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user