From 9da7bdb27de6a2368a48fc0c245b83c1e35587de Mon Sep 17 00:00:00 2001 From: Gerson Alexander Pardo Gamez Date: Wed, 11 Oct 2017 12:34:01 -0500 Subject: [PATCH] Fixed fireOnLeave when connection is already closed Former-commit-id: 664afda8f052b9c7596f82d66cc4faeb6e09148d --- websocket/connection.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket/connection.go b/websocket/connection.go index ef18b967..a928b628 100644 --- a/websocket/connection.go +++ b/websocket/connection.go @@ -477,6 +477,10 @@ func (c *connection) OnLeave(roomLeaveCb LeaveRoomFunc) { } func (c *connection) fireOnLeave(roomName string) { + // check if connection is already closed + if c == nil { + return + } // fire the onRoomLeaveListeners for i := range c.onRoomLeaveListeners { c.onRoomLeaveListeners[i](roomName)