Skip to content

Commit

Permalink
Merge pull request googollee#254 from chappjc/clean-disconnect
Browse files Browse the repository at this point in the history
conn: On Close, leave all rooms, and call the disconnect handler
  • Loading branch information
erkie authored Aug 18, 2019
2 parents aa8a717 + 90e10de commit 3f1229f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ func newConn(c engineio.Conn, handlers map[string]*namespaceHandler, broadcast B
func (c *conn) Close() error {
var err error
c.closeOnce.Do(func() {
// For each namespace, leave all rooms, and call the disconnect handler.
for ns, nc := range c.namespaces {
nc.LeaveAll()
if nh := c.handlers[ns]; nh != nil {
nh.onDisconnect(nc, "bye")
}
}
err = c.Conn.Close()
close(c.quitChan)
})
Expand Down

0 comments on commit 3f1229f

Please sign in to comment.