Private
Public Access
1
0

fix game
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Failing after 8m17s

This commit is contained in:
Sebastian Unterschütz
2026-03-21 20:32:53 +01:00
parent f7df54431c
commit 188e9c2cc2
6 changed files with 420 additions and 101 deletions

View File

@@ -27,6 +27,22 @@ type WebSocketMessage struct {
Payload interface{} `json:"payload"`
}
// disconnectFromServer trennt die bestehende WebSocket-Verbindung sauber
func (g *Game) disconnectFromServer() {
if g.wsConn != nil {
// stopChan schließen ohne Panic falls schon geschlossen
select {
case <-g.wsConn.stopChan:
// bereits geschlossen
default:
close(g.wsConn.stopChan)
}
g.wsConn.conn.Close()
g.wsConn = nil
}
g.connected = false
}
// connectToServer verbindet sich über WebSocket mit dem Gateway (Native Desktop)
func (g *Game) connectToServer() {
serverURL := "ws://localhost:8080/ws"