341 else |
341 else |
342 return (clID, serverInfo{lastLogins = (host client, connectTime client) : newLogins}, updatedClients, rooms) |
342 return (clID, serverInfo{lastLogins = (host client, connectTime client) : newLogins}, updatedClients, rooms) |
343 |
343 |
344 |
344 |
345 processAction (clID, serverInfo, clients, rooms) PingAll = do |
345 processAction (clID, serverInfo, clients, rooms) PingAll = do |
|
346 (_, _, newClients, newRooms) <- foldM kickTimeouted (clID, serverInfo, clients, rooms) $ elems clients |
346 processAction (clID, |
347 processAction (clID, |
347 serverInfo, |
348 serverInfo, |
348 map (\cl -> cl{pingsQueue = pingsQueue cl + 1}) clients, |
349 Data.IntMap.map (\cl -> cl{pingsQueue = pingsQueue cl + 1}) newClients, |
349 rooms) $ AnswerAll ["PING"] |
350 newRooms) $ AnswerAll ["PING"] |
350 |
351 where |
|
352 kickTimeouted (clID, serverInfo, clients, rooms) client = |
|
353 if pingsQueue client > 0 then |
|
354 processAction (clientUID client, serverInfo, clients, rooms) $ ByeClient "Ping timeout" |
|
355 else |
|
356 return (clID, serverInfo, clients, rooms) |