mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-11 08:07:31 +02:00
WS do not connect if already connected.
This commit is contained in:
parent
1677e38935
commit
25fec63455
1 changed files with 13 additions and 0 deletions
|
@ -135,6 +135,19 @@ func (ws *WebSocketManagerCtx) Upgrade(w http.ResponseWriter, r *http.Request) e
|
||||||
return connection.Close()
|
return connection.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if session.Connected() {
|
||||||
|
// TODO: Refactor
|
||||||
|
if err = connection.WriteJSON(
|
||||||
|
message.SystemDisconnect{
|
||||||
|
Event: event.SYSTEM_DISCONNECT,
|
||||||
|
Message: "already connected",
|
||||||
|
}); err != nil {
|
||||||
|
ws.logger.Error().Err(err).Msg("failed to send disconnect")
|
||||||
|
}
|
||||||
|
|
||||||
|
return connection.Close()
|
||||||
|
}
|
||||||
|
|
||||||
session.SetWebSocketPeer(&WebSocketPeerCtx{
|
session.SetWebSocketPeer(&WebSocketPeerCtx{
|
||||||
session: session,
|
session: session,
|
||||||
ws: ws,
|
ws: ws,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue