mirror of
https://github.com/kataras/iris.git
synced 2025-12-19 02:47:04 +00:00
Fix panic error in concurrent calling with websocket.Connection.Emit()
Former-commit-id: b5d0ecd61547a297c320867af0a8abf208f0f743
This commit is contained in:
@@ -352,7 +352,10 @@ func (s *Server) GetConnectionsByRoom(roomName string) []Connection {
|
|||||||
// let's keep it unexported for the best.
|
// let's keep it unexported for the best.
|
||||||
func (s *Server) emitMessage(from, to string, data []byte) {
|
func (s *Server) emitMessage(from, to string, data []byte) {
|
||||||
if to != All && to != Broadcast {
|
if to != All && to != Broadcast {
|
||||||
if s.rooms[to] != nil {
|
s.mu.RLock()
|
||||||
|
room := s.rooms[to]
|
||||||
|
s.mu.RUnlock()
|
||||||
|
if room != nil {
|
||||||
// it suppose to send the message to a specific room/or a user inside its own room
|
// 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 s.rooms[to] {
|
||||||
if c, ok := s.getConnection(connectionIDInsideRoom); ok {
|
if c, ok := s.getConnection(connectionIDInsideRoom); ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user