khatru: only kill connection once.
This commit is contained in:
+11
-8
@@ -108,17 +108,20 @@ func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
killOnce := sync.Once{}
|
||||||
kill := func() {
|
kill := func() {
|
||||||
if nil != rl.OnDisconnect {
|
killOnce.Do(func() {
|
||||||
rl.OnDisconnect(ctx)
|
if nil != rl.OnDisconnect {
|
||||||
}
|
rl.OnDisconnect(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
cancel()
|
cancel()
|
||||||
ws.cancel()
|
ws.cancel()
|
||||||
ws.conn.Close()
|
ws.conn.Close()
|
||||||
|
|
||||||
rl.removeClientAndListeners(ws)
|
rl.removeClientAndListeners(ws)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user