mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-10 07:37:26 +02:00
+ CanConnect.
This commit is contained in:
parent
0a201d50c8
commit
d2ffac3d4b
1 changed files with 16 additions and 3 deletions
|
@ -155,11 +155,24 @@ func (ws *WebSocketManagerCtx) Upgrade(w http.ResponseWriter, r *http.Request) e
|
|||
if err != nil {
|
||||
ws.logger.Warn().Err(err).Msg("authentication failed")
|
||||
|
||||
// TODO: Refactor
|
||||
// TODO: Refactor, return error code.
|
||||
if err = connection.WriteJSON(
|
||||
message.SystemDisconnect{
|
||||
Event: event.SYSTEM_DISCONNECT,
|
||||
Message: "authentication failed",
|
||||
Message: err.Error(),
|
||||
}); err != nil {
|
||||
ws.logger.Error().Err(err).Msg("failed to send disconnect")
|
||||
}
|
||||
|
||||
return connection.Close()
|
||||
}
|
||||
|
||||
if !session.CanConnect() {
|
||||
// TODO: Refactor, return error code.
|
||||
if err = connection.WriteJSON(
|
||||
message.SystemDisconnect{
|
||||
Event: event.SYSTEM_DISCONNECT,
|
||||
Message: "connection disabled",
|
||||
}); err != nil {
|
||||
ws.logger.Error().Err(err).Msg("failed to send disconnect")
|
||||
}
|
||||
|
@ -168,7 +181,7 @@ func (ws *WebSocketManagerCtx) Upgrade(w http.ResponseWriter, r *http.Request) e
|
|||
}
|
||||
|
||||
if session.IsConnected() {
|
||||
// TODO: Refactor
|
||||
// TODO: Refactor, return error code.
|
||||
if err = connection.WriteJSON(
|
||||
message.SystemDisconnect{
|
||||
Event: event.SYSTEM_DISCONNECT,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue