--- a/gameServer/Actions.hs Fri Mar 27 20:29:38 2009 +0000
+++ b/gameServer/Actions.hs Fri Mar 27 20:36:50 2009 +0000
@@ -343,8 +343,14 @@
processAction (clID, serverInfo, clients, rooms) PingAll = do
+ (_, _, newClients, newRooms) <- foldM kickTimeouted (clID, serverInfo, clients, rooms) $ elems clients
processAction (clID,
serverInfo,
- map (\cl -> cl{pingsQueue = pingsQueue cl + 1}) clients,
- rooms) $ AnswerAll ["PING"]
-
+ Data.IntMap.map (\cl -> cl{pingsQueue = pingsQueue cl + 1}) newClients,
+ newRooms) $ AnswerAll ["PING"]
+ where
+ kickTimeouted (clID, serverInfo, clients, rooms) client =
+ if pingsQueue client > 0 then
+ processAction (clientUID client, serverInfo, clients, rooms) $ ByeClient "Ping timeout"
+ else
+ return (clID, serverInfo, clients, rooms)
--- a/gameServer/HWProtoCore.hs Fri Mar 27 20:29:38 2009 +0000
+++ b/gameServer/HWProtoCore.hs Fri Mar 27 20:36:50 2009 +0000
@@ -24,6 +24,15 @@
msg = if not $ null xs then head xs else ""
+handleCmd clID clients _ ["PONG"] =
+ if pingsQueue client == 0 then
+ [ProtocolError "Protocol violation"]
+ else
+ [ModifyClient (\cl -> cl{pingsQueue = pingsQueue cl - 1})]
+ where
+ client = clients IntMap.! clID
+
+
handleCmd clID clients rooms cmd =
if not $ logonPassed client then
handleCmd_NotEntered clID clients rooms cmd