temp push

This commit is contained in:
2025-12-02 10:34:45 +01:00
parent 8f7db6256b
commit 7a30adc2e8
7 changed files with 73 additions and 25 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/gorilla/websocket"
)
func (wsg *WebsocketGateway) handlePush(w http.ResponseWriter, r *http.Request) {
func (wsg *WebsocketGateway) handleSync(w http.ResponseWriter, r *http.Request) {
conn, err := wsg.validateAndUpgradeConnection(w, r)
if err != nil {
return
@@ -65,7 +65,7 @@ func (wsg *WebsocketGateway) handlePush(w http.ResponseWriter, r *http.Request)
return
}
wsg.registerConn(conn, meta)
wsg.registerConn(conn, meta, "mod")
wsg.logger.Info("Mod connected via Websocket.", "remote", conn.RemoteAddr().String(), "server_id", mhs.ServerID)
go wsg.modReadLoop(conn, meta) // replace with external handler mayhaps
@@ -81,11 +81,15 @@ func (wsg *WebsocketGateway) handlePush(w http.ResponseWriter, r *http.Request)
meta.ID = bhs.BotID
if ok := wsg.registerConn(conn, meta, "bot"); !ok {
wsg.sendWebsocketError(conn, "Bot already connected.", 409)
return
}
if err = wsg.sendWebsocketResponse(conn, GatewayAck{Status: "connected", Type: "bot"}); err != nil {
return
}
wsg.registerConn(conn, meta)
wsg.logger.Info("Bot connected via Websocket.", "remote", conn.RemoteAddr().String(), "bot_id", bhs.BotID)
go wsg.botReadLoop(conn, meta) // replace with external handler mayhaps
@@ -97,12 +101,8 @@ func (wsg *WebsocketGateway) handlePush(w http.ResponseWriter, r *http.Request)
}
}
func (wsg *WebsocketGateway) handleReady(w http.ResponseWriter, r *http.Request) {}
func (wsg *WebsocketGateway) handleHealth(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
_ = json.NewEncoder(w).Encode(map[string]interface{}{"status": "healthy"})
}
func (wsg *WebsocketGateway) handleRegister(w http.ResponseWriter, r *http.Request) {}