gameServer/ServerState.hs
changeset 3458 11cd56019f00
child 3501 a3159a410e5c
equal deleted inserted replaced
3457:2c29b75746f3 3458:11cd56019f00
       
     1 module ServerState
       
     2     (
       
     3     module RoomsAndClients,
       
     4     clientRoomA,
       
     5     ServerState(..),
       
     6     clients
       
     7     ) where
       
     8 
       
     9 import Control.Monad.State
       
    10 ----------------------
       
    11 import RoomsAndClients
       
    12 import CoreTypes
       
    13 
       
    14 data ServerState = ServerState {
       
    15         clientIndex :: Maybe ClientIndex,
       
    16         serverInfo :: ServerInfo,
       
    17         roomsClients :: MRnC
       
    18     }
       
    19 
       
    20 
       
    21 clientRoomA :: StateT ServerState IO RoomIndex
       
    22 clientRoomA = do
       
    23     (Just ci) <- gets clientIndex
       
    24     rnc <- gets roomsClients
       
    25     liftIO $ clientRoomM rnc ci
       
    26 
       
    27 clients :: (ClientInfo -> a) -> StateT ServerState IO a
       
    28 clients f = do
       
    29     (Just ci) <- gets clientIndex
       
    30     rnc <- gets roomsClients
       
    31     liftIO $ clientsM rnc f ci
       
    32