From cc679280ff44d3e527b26c5d3f7f0630f727dd3d Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Wed, 8 Aug 2018 13:29:01 +0300 Subject: [PATCH] fast-fix from prev commit Former-commit-id: 3e1160018eb25cd844785fb951af0d31776df04c --- websocket/server.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket/server.go b/websocket/server.go index 50b71126..f704a05e 100644 --- a/websocket/server.go +++ b/websocket/server.go @@ -37,7 +37,7 @@ type ( config Config connections sync.Map // key = the Connection ID. rooms map[string][]string // by default a connection is joined to a room which has the connection id as its name - mu sync.RWMutex // for rooms and connections, they should be in-sync between them as well. + mu sync.RWMutex // for rooms. onConnectionListeners []ConnectionFunc //connectionPool sync.Pool // sadly we can't make this because the websocket connection is live until is closed. upgrader websocket.Upgrader @@ -373,26 +373,26 @@ func (s *Server) emitMessage(from, to string, data []byte) { connID, ok := k.(string) if !ok { // should never happen. - return false + return true } if to != All && to != connID { // if it's not suppose to send to all connections (including itself) if to == Broadcast && from == connID { // if broadcast to other connections except this // here we do the opossite of previous block, // just skip this connection when it's suppose to send the message to all connections except the sender. - return false + return true } } // not necessary cast. conn, ok := v.(*connection) - if !ok { - return false + if ok { + // send to the client(s) when the top validators passed + conn.writeDefault(data) } - // send to the client(s) when the top validators passed - conn.writeDefault(data) - return true + + return ok }) } }