gameServer/ServerState.hs
changeset 3501 a3159a410e5c
parent 3458 11cd56019f00
child 3502 ad38c653b7d9
equal deleted inserted replaced
3500:af8390d807d6 3501:a3159a410e5c
     1 module ServerState
     1 module ServerState
     2     (
     2     (
     3     module RoomsAndClients,
     3     module RoomsAndClients,
     4     clientRoomA,
     4     clientRoomA,
     5     ServerState(..),
     5     ServerState(..),
     6     clients
     6     client's,
       
     7     allClientsS
     7     ) where
     8     ) where
     8 
     9 
     9 import Control.Monad.State
    10 import Control.Monad.State
    10 ----------------------
    11 ----------------------
    11 import RoomsAndClients
    12 import RoomsAndClients
    22 clientRoomA = do
    23 clientRoomA = do
    23     (Just ci) <- gets clientIndex
    24     (Just ci) <- gets clientIndex
    24     rnc <- gets roomsClients
    25     rnc <- gets roomsClients
    25     liftIO $ clientRoomM rnc ci
    26     liftIO $ clientRoomM rnc ci
    26 
    27 
    27 clients :: (ClientInfo -> a) -> StateT ServerState IO a
    28 client's :: (ClientInfo -> a) -> StateT ServerState IO a
    28 clients f = do
    29 client's f = do
    29     (Just ci) <- gets clientIndex
    30     (Just ci) <- gets clientIndex
    30     rnc <- gets roomsClients
    31     rnc <- gets roomsClients
    31     liftIO $ clientsM rnc f ci
    32     liftIO $ client'sM rnc f ci
    32     
    33     
       
    34 allClientsS :: StateT ServerState IO [ClientInfo]
       
    35 allClientsS = gets roomsClients >>= liftIO . clientsM