Graceful disconnect
This commit is contained in:
@@ -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...)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user