forked from MTSR/mapserver
ws close
This commit is contained in:
parent
5608be900e
commit
7b5b88a75e
@ -64,17 +64,16 @@ func (t *WS) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
||||
t.channels[id] = ch
|
||||
t.mutex.Unlock()
|
||||
|
||||
defer func() {
|
||||
for {
|
||||
data := <-ch
|
||||
err := conn.WriteMessage(websocket.TextMessage, data)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
t.mutex.Lock()
|
||||
delete(t.channels, id)
|
||||
close(ch)
|
||||
t.mutex.Unlock()
|
||||
}()
|
||||
|
||||
for {
|
||||
|
||||
data := <-ch
|
||||
conn.WriteMessage(websocket.TextMessage, data)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user