disconnect

This commit is contained in:
zhouyuyan
2017-09-12 15:37:05 +08:00
parent 49385e52fd
commit 4646042b7f
2 changed files with 9 additions and 3 deletions

View File

@@ -467,13 +467,19 @@ func (c *client) ProcessPing() {
}
func (c *client) Close() {
if c.status == Disconnected {
return
}
c.smu.Lock()
c.status = Disconnected
c.smu.Unlock()
if c.conn != nil {
c.conn.Close()
c.conn = nil
}
c.smu.Unlock()
b := c.broker
subs := c.subs
if b != nil {