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] accounts := registeredAccounts[mxid]
if prev_acct, ok := accounts[name]; ok { if prev_acct, ok := accounts[name]; ok {
prev_acct.Conn.Close()
prev_acct.JoinedRooms = map[RoomID]bool{}
if protocol != prev_acct.Protocol { if protocol != prev_acct.Protocol {
return fmt.Errorf("Wrong protocol") return fmt.Errorf("Wrong protocol")
} }
if !reflect.DeepEqual(config, prev_acct.Config) { if !reflect.DeepEqual(config, prev_acct.Config) {
prev_acct.Conn.Close()
prev_acct.JoinedRooms = map[RoomID]bool{}
prev_acct.Config = config prev_acct.Config = config
go prev_acct.connect() go prev_acct.connect()
} }

View file

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

View file

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