gameServer/Actions.hs
changeset 4914 5c33bb53c1e5
parent 4909 dc6482438674
child 4917 8ff92bdc9f98
equal deleted inserted replaced
4913:f0d48df35f86 4914:5c33bb53c1e5
    51     | ProcessAccountInfo AccountInfo
    51     | ProcessAccountInfo AccountInfo
    52     | AddClient ClientInfo
    52     | AddClient ClientInfo
    53     | DeleteClient ClientIndex
    53     | DeleteClient ClientIndex
    54     | PingAll
    54     | PingAll
    55     | StatsAction
    55     | StatsAction
       
    56     | RestartServer Bool
    56 
    57 
    57 type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
    58 type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
    58 
    59 
    59 instance NFData Action where
    60 instance NFData Action where
    60     rnf (AnswerClients chans msg) = chans `deepseq` msg `deepseq` ()
    61     rnf (AnswerClients chans msg) = chans `deepseq` msg `deepseq` ()
   415             when (pq > 0) $
   416             when (pq > 0) $
   416                 withStateT (\as -> as{clientIndex = Just ci}) $
   417                 withStateT (\as -> as{clientIndex = Just ci}) $
   417                     processAction (ByeClient "Ping timeout")
   418                     processAction (ByeClient "Ping timeout")
   418 
   419 
   419 
   420 
   420 processAction (StatsAction) = do
   421 processAction StatsAction = do
   421     rnc <- gets roomsClients
   422     rnc <- gets roomsClients
   422     si <- gets serverInfo
   423     si <- gets serverInfo
   423     (roomsNum, clientsNum) <- io $ withRoomsAndClients rnc stats
   424     (roomsNum, clientsNum) <- io $ withRoomsAndClients rnc stats
   424     io $ writeChan (dbQueries si) $ SendStats clientsNum (roomsNum - 1)
   425     io $ writeChan (dbQueries si) $ SendStats clientsNum (roomsNum - 1)
   425     where
   426     where
   426           stats irnc = (length $ allRooms irnc, length $ allClients irnc)
   427           stats irnc = (length $ allRooms irnc, length $ allClients irnc)
   427 
   428 
       
   429 processAction (RestartServer useForce) = do
       
   430     return ()