Fix maintenance of connected status

This commit is contained in:
Alex 2020-02-26 23:01:34 +01:00
parent 8a5ed3f507
commit 717606a54d
3 changed files with 5 additions and 3 deletions

View file

@ -34,13 +34,13 @@ func SetAccount(mxid string, name string, protocol string, config map[string]str
accounts := registeredAccounts[mxid]
if prev_acct, ok := accounts[name]; ok {
prev_acct.Conn.Close()
prev_acct.JoinedRooms = map[RoomID]bool{}
if protocol != prev_acct.Protocol {
return fmt.Errorf("Wrong protocol")
}
if !reflect.DeepEqual(config, prev_acct.Config) {
prev_acct.Conn.Close()
prev_acct.JoinedRooms = map[RoomID]bool{}
prev_acct.Config = config
go prev_acct.connect()
}

View file

@ -251,6 +251,7 @@ func (irc *IRC) Send(event *Event) error {
func (irc *IRC) Close() {
conn := irc.conn
irc.conn = nil
irc.connected = false
if conn != nil {
conn.Close()
}

View file

@ -351,4 +351,5 @@ func (xm *XMPP) Close() {
}
xm.conn = nil
xm.connectorLoopNum += 1
xm.connected = false
}