fixed logs and config locations, updated connection closure handling

This commit is contained in:
2025-12-10 11:22:09 +01:00
parent 709abb30fa
commit 27609dba2b
7 changed files with 75 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ package ws
import (
"fmt"
"homestead/homestead_gateway/util"
"time"
"github.com/gorilla/websocket"
@@ -92,8 +93,7 @@ func (r *Registry) RegisterMod(channelID, serverID string, conn *websocket.Conn)
defer e.mu.Unlock()
if e.Mod != nil && e.Mod.Conn != nil {
_ = e.Mod.Conn.Close()
util.CloseConn(e.Mod.Conn)
}
e.Mod = &ConnWrapper{Conn: conn, ServerID: serverID, LastSeen: time.Now()}
@@ -106,7 +106,7 @@ func (r *Registry) RegisterBot(conn *websocket.Conn) {
r.botMu.Lock()
if r.bot != nil && r.bot.Conn != nil {
_ = r.bot.Conn.Close()
r.UnregisterBot()
}
r.bot = &ConnWrapper{Conn: conn, LastSeen: time.Now()}
@@ -127,7 +127,7 @@ func (r *Registry) UnregisterMod(channelID string) {
e.mu.Unlock()
if modConn != nil && modConn.Conn != nil {
closeConn(modConn.Conn)
util.CloseConn(modConn.Conn)
}
}
@@ -138,7 +138,7 @@ func (r *Registry) UnregisterBot() {
r.botMu.Unlock()
if botConn != nil && botConn.Conn != nil {
closeConn(botConn.Conn)
util.CloseConn(botConn.Conn)
}
}
@@ -152,7 +152,6 @@ func (r *Registry) Send(channelID string, out GatewayMessageOut, sendOverConn fu
if err := sendOverConn(b.Conn, out); err == nil {
return true, false, nil
}
_ = b.Conn.Close()
r.UnregisterBot()
}
@@ -176,7 +175,6 @@ func (r *Registry) Send(channelID string, out GatewayMessageOut, sendOverConn fu
if err := sendOverConn(mod.Conn, out); err == nil {
return true, false, nil
}
_ = mod.Conn.Close()
r.UnregisterMod(channelID)
}