Fix panic error in concurrent calling with websocket.Connection.Emit()

Former-commit-id: 4c5cc222e9a43b18a86adb35bfafe4a278fd880e
This commit is contained in:
Eryx 2018-10-16 13:25:28 +08:00
parent d2c3b90bc4
commit 1f1dfcca1c

View File

@ -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 {