1
0
forked from MTSR/mapserver
This commit is contained in:
NatureFreshMilk 2019-02-07 08:08:54 +01:00
parent 5608be900e
commit 7b5b88a75e

View File

@ -64,17 +64,16 @@ func (t *WS) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
t.channels[id] = ch t.channels[id] = ch
t.mutex.Unlock() t.mutex.Unlock()
defer func() { for {
data := <-ch
err := conn.WriteMessage(websocket.TextMessage, data)
if err != nil {
break
}
}
t.mutex.Lock() t.mutex.Lock()
delete(t.channels, id) delete(t.channels, id)
close(ch) close(ch)
t.mutex.Unlock() t.mutex.Unlock()
}()
for {
data := <-ch
conn.WriteMessage(websocket.TextMessage, data)
}
} }