Do not remove a disconnected player from the 'player' slice since that crashes the server
This commit is contained in:
parent
732d759f84
commit
db754f5601
@ -8,7 +8,6 @@ import (
|
|||||||
"mchess_server/types"
|
"mchess_server/types"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/samber/lo"
|
|
||||||
"nhooyr.io/websocket"
|
"nhooyr.io/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -210,11 +209,6 @@ func (game Game) broadcastGameEnd(reason GameEndedReason) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (game *Game) playerDisconnected(p *Player) {
|
func (game *Game) playerDisconnected(p *Player) {
|
||||||
log.Println(string(p.color), " disconnected")
|
|
||||||
playerStillInGame := lo.Filter(game.players, func(player *Player, _ int) bool {
|
|
||||||
return player.color != p.color
|
|
||||||
})
|
|
||||||
game.players = playerStillInGame
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game *Game) SetWebsocketConnectionFor(ctx context.Context, p *Player, ws *websocket.Conn) {
|
func (game *Game) SetWebsocketConnectionFor(ctx context.Context, p *Player, ws *websocket.Conn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user