mirror of
https://github.com/HexCardGames/HexDeck.git
synced 2025-09-05 03:08:39 +02:00
fix(backend): check that player socket exists before trying to send data
This commit is contained in:
@ -64,6 +64,10 @@ func unpackData(datas []any, target interface{}) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func verifyPlayerIsActivePlayer(room *types.Room, target *types.Player) bool {
|
func verifyPlayerIsActivePlayer(room *types.Room, target *types.Player) bool {
|
||||||
|
if target.Connection.Socket == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if room.GameState != types.StateRunning {
|
if room.GameState != types.StateRunning {
|
||||||
target.Connection.Socket.Emit("Status", types.S2C_Status{
|
target.Connection.Socket.Emit("Status", types.S2C_Status{
|
||||||
IsError: true,
|
IsError: true,
|
||||||
|
@ -141,6 +141,9 @@ func OnPlayerStateUpdate(room *types.Room, player *types.Player, skipDBUpdate bo
|
|||||||
if !skipDBUpdate {
|
if !skipDBUpdate {
|
||||||
db.Conn.UpdateRoom(room)
|
db.Conn.UpdateRoom(room)
|
||||||
}
|
}
|
||||||
|
if player.Connection.Socket == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
player.Connection.Socket.Emit("OwnCards", types.BuildOwnCardsPacket(room, player))
|
player.Connection.Socket.Emit("OwnCards", types.BuildOwnCardsPacket(room, player))
|
||||||
BroadcastInRoom(room, "PlayerState", types.BuildPlayerStatePacket(room, player))
|
BroadcastInRoom(room, "PlayerState", types.BuildPlayerStatePacket(room, player))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user