Skip to content
This repository was archived by the owner on Sep 29, 2024. It is now read-only.

Commit 3f1229f

Browse files
authored
Merge pull request #254 from chappjc/clean-disconnect
conn: On Close, leave all rooms, and call the disconnect handler
2 parents aa8a717 + 90e10de commit 3f1229f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

conn.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ func newConn(c engineio.Conn, handlers map[string]*namespaceHandler, broadcast B
8484
func (c *conn) Close() error {
8585
var err error
8686
c.closeOnce.Do(func() {
87+
// For each namespace, leave all rooms, and call the disconnect handler.
88+
for ns, nc := range c.namespaces {
89+
nc.LeaveAll()
90+
if nh := c.handlers[ns]; nh != nil {
91+
nh.onDisconnect(nc, "bye")
92+
}
93+
}
8794
err = c.Conn.Close()
8895
close(c.quitChan)
8996
})

0 commit comments

Comments
 (0)