gameServer/RoomsAndClients.hs
changeset 3458 11cd56019f00
parent 3436 288fcbdb77b6
child 3501 a3159a410e5c
equal deleted inserted replaced
3457:2c29b75746f3 3458:11cd56019f00
    14     moveClientToLobby,
    14     moveClientToLobby,
    15     moveClientToRoom,
    15     moveClientToRoom,
    16     clientRoom,
    16     clientRoom,
    17     clientRoomM,
    17     clientRoomM,
    18     client,
    18     client,
       
    19     clientsM,
    19     allClients,
    20     allClients,
    20     withRoomsAndClients,
    21     withRoomsAndClients,
    21     showRooms,
    22     showRooms,
    22     roomClients
    23     roomClients
    23     ) where
    24     ) where
   133 
   134 
   134 
   135 
   135 clientRoomM :: MRoomsAndClients r c -> ClientIndex -> IO RoomIndex
   136 clientRoomM :: MRoomsAndClients r c -> ClientIndex -> IO RoomIndex
   136 clientRoomM (MRoomsAndClients (_, clients)) (ClientIndex ci) = liftM clientRoom' (clients `readElem` ci)
   137 clientRoomM (MRoomsAndClients (_, clients)) (ClientIndex ci) = liftM clientRoom' (clients `readElem` ci)
   137 
   138 
       
   139 clientsM :: MRoomsAndClients r c -> (c -> a) -> ClientIndex -> IO a
       
   140 clientsM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
       
   141 
   138 
   142 
   139 withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
   143 withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
   140 withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
   144 withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
   141     withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))
   145     withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))
   142 
   146