From 1f1dfcca1ce0cdb361398e4198e0bf3445cf9805 Mon Sep 17 00:00:00 2001 From: Eryx Date: Tue, 16 Oct 2018 13:25:28 +0800 Subject: [PATCH] Fix panic error in concurrent calling with websocket.Connection.Emit() Former-commit-id: 4c5cc222e9a43b18a86adb35bfafe4a278fd880e --- websocket/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket/server.go b/websocket/server.go index 4055d0d5..a88f1806 100644 --- a/websocket/server.go +++ b/websocket/server.go @@ -357,7 +357,7 @@ func (s *Server) emitMessage(from, to string, data []byte) { s.mu.RUnlock() if room != nil { // it suppose to send the message to a specific room/or a user inside its own room - for _, connectionIDInsideRoom := range s.rooms[to] { + for _, connectionIDInsideRoom := range room { if c, ok := s.getConnection(connectionIDInsideRoom); ok { c.writeDefault(data) //send the message to the client(s) } else {