Graceful disconnect

This commit is contained in:
2025-01-18 22:39:43 +01:00
parent b73d8de851
commit b44cdab611
3 changed files with 22 additions and 8 deletions
+9
View File
@@ -118,6 +118,15 @@ func handleConnection(conn net.Conn) {
// Queue the actions for processing
if batch.PlayerId == int32(playerID) {
for _, action := range batch.Actions {
if action.Type == pb.Action_DISCONNECT {
log.Printf("Player %d disconnected gracefully", playerID)
delete(players, playerID)
delete(playerConns, playerID)
delete(actionQueue, playerID)
return
}
}
actionQueue[playerID] = append(actionQueue[playerID], batch.Actions...)
}
}