gameServer/RoomsAndClients.hs
author nemo
Fri, 20 Aug 2010 11:54:14 -0400
changeset 3747 76a197793b62
parent 3741 73246d25dfe1
child 3901 124b4755914b
permissions -rw-r--r--
Some more that were not native
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3747
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     1
module RoomsAndClients(
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     2
    RoomIndex(),
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     3
    ClientIndex(),
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     4
    MRoomsAndClients(),
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     5
    IRoomsAndClients(),
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     6
    newRoomsAndClients,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     7
    addRoom,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     8
    addClient,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
     9
    removeRoom,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    10
    removeClient,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    11
    modifyRoom,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    12
    modifyClient,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    13
    lobbyId,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    14
    moveClientToLobby,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    15
    moveClientToRoom,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    16
    clientRoom,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    17
    clientRoomM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    18
    clientExists,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    19
    client,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    20
    room,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    21
    client'sM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    22
    room'sM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    23
    allClientsM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    24
    clientsM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    25
    roomClientsM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    26
    roomClientsIndicesM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    27
    withRoomsAndClients,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    28
    allRooms,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    29
    allClients,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    30
    clientRoom,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    31
    showRooms,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    32
    roomClients
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    33
    ) where
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    34
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    35
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    36
import Store
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    37
import Control.Monad
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    38
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    39
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    40
data Room r = Room {
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    41
    roomClients' :: [ClientIndex],
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    42
    room' :: r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    43
    }
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    44
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    45
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    46
data Client c = Client {
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    47
    clientRoom' :: RoomIndex,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    48
    client' :: c
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    49
    }
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    50
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    51
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    52
newtype RoomIndex = RoomIndex ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    53
    deriving (Eq)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    54
newtype ClientIndex = ClientIndex ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    55
    deriving (Eq, Show, Read, Ord)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    56
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    57
instance Show RoomIndex where
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    58
    show (RoomIndex i) = 'r' : show i
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    59
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    60
unRoomIndex :: RoomIndex -> ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    61
unRoomIndex (RoomIndex r) = r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    62
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    63
unClientIndex :: ClientIndex -> ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    64
unClientIndex (ClientIndex c) = c
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    65
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    66
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    67
newtype MRoomsAndClients r c = MRoomsAndClients (MStore (Room r), MStore (Client c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    68
newtype IRoomsAndClients r c = IRoomsAndClients (IStore (Room r), IStore (Client c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    69
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    70
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    71
lobbyId :: RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    72
lobbyId = RoomIndex firstIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    73
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    74
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    75
newRoomsAndClients :: r -> IO (MRoomsAndClients r c)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    76
newRoomsAndClients r = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    77
    rooms <- newStore
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    78
    clients <- newStore
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    79
    let rnc = MRoomsAndClients (rooms, clients)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    80
    ri <- addRoom rnc r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    81
    when (ri /= lobbyId) $ error "Empty struct inserts not at firstIndex index"
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    82
    return rnc
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    83
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    84
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    85
roomAddClient :: ClientIndex -> Room r -> Room r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    86
roomAddClient cl room = room{roomClients' = cl : roomClients' room}
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    87
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    88
roomRemoveClient :: ClientIndex -> Room r -> Room r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    89
roomRemoveClient cl room = room{roomClients' = filter (/= cl) $ roomClients' room}
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    90
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    91
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    92
addRoom :: MRoomsAndClients r c -> r -> IO RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    93
addRoom (MRoomsAndClients (rooms, _)) room = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    94
    i <- addElem rooms (Room  [] room)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    95
    return $ RoomIndex i
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    96
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    97
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    98
addClient :: MRoomsAndClients r c -> c -> IO ClientIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    99
addClient (MRoomsAndClients (rooms, clients)) client = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   100
    i <- addElem clients (Client lobbyId client)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   101
    modifyElem rooms (roomAddClient (ClientIndex i)) (unRoomIndex lobbyId)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   102
    return $ ClientIndex i
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   103
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   104
removeRoom :: MRoomsAndClients r c -> RoomIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   105
removeRoom rnc@(MRoomsAndClients (rooms, _)) room@(RoomIndex ri) 
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   106
    | room == lobbyId = error "Cannot delete lobby"
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   107
    | otherwise = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   108
        clIds <- liftM roomClients' $ readElem rooms ri
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   109
        forM_ clIds (moveClientToLobby rnc)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   110
        removeElem rooms ri
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   111
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   112
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   113
removeClient :: MRoomsAndClients r c -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   114
removeClient (MRoomsAndClients (rooms, clients)) cl@(ClientIndex ci) = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   115
    RoomIndex ri <- liftM clientRoom' $ readElem clients ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   116
    modifyElem rooms (roomRemoveClient cl) ri
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   117
    removeElem clients ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   118
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   119
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   120
modifyRoom :: MRoomsAndClients r c -> (r -> r) -> RoomIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   121
modifyRoom (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = modifyElem rooms (\r -> r{room' = f $ room' r}) ri
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   122
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   123
modifyClient :: MRoomsAndClients r c -> (c -> c) -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   124
modifyClient (MRoomsAndClients (_, clients)) f (ClientIndex ci) = modifyElem clients (\c -> c{client' = f $ client' c}) ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   125
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   126
moveClientInRooms :: MRoomsAndClients r c -> RoomIndex -> RoomIndex -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   127
moveClientInRooms (MRoomsAndClients (rooms, clients)) (RoomIndex riFrom) rt@(RoomIndex riTo) cl@(ClientIndex ci) = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   128
    modifyElem rooms (roomRemoveClient cl) riFrom
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   129
    modifyElem rooms (roomAddClient cl) riTo
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   130
    modifyElem clients (\c -> c{clientRoom' = rt}) ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   131
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   132
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   133
moveClientToLobby :: MRoomsAndClients r c -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   134
moveClientToLobby rnc ci = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   135
    room <- clientRoomM rnc ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   136
    moveClientInRooms rnc room lobbyId ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   137
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   138
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   139
moveClientToRoom :: MRoomsAndClients r c -> RoomIndex -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   140
moveClientToRoom rnc ri ci = moveClientInRooms rnc lobbyId ri ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   141
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   142
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   143
clientExists :: MRoomsAndClients r c -> ClientIndex -> IO Bool
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   144
clientExists (MRoomsAndClients (_, clients)) (ClientIndex ci) = elemExists clients ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   145
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   146
clientRoomM :: MRoomsAndClients r c -> ClientIndex -> IO RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   147
clientRoomM (MRoomsAndClients (_, clients)) (ClientIndex ci) = liftM clientRoom' (clients `readElem` ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   148
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   149
client'sM :: MRoomsAndClients r c -> (c -> a) -> ClientIndex -> IO a
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   150
client'sM (MRoomsAndClients (_, clients)) f (ClientIndex ci) = liftM (f . client') (clients `readElem` ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   151
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   152
room'sM :: MRoomsAndClients r c -> (r -> a) -> RoomIndex -> IO a
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   153
room'sM (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = liftM (f . room') (rooms `readElem` ri)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   154
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   155
allClientsM :: MRoomsAndClients r c -> IO [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   156
allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   157
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   158
clientsM :: MRoomsAndClients r c -> IO [c]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   159
clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   160
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   161
roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   162
roomClientsIndicesM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   163
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   164
roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   165
roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   166
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   167
withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   168
withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   169
    withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   170
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   171
----------------------------------------
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   172
----------- IRoomsAndClients -----------
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   173
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   174
showRooms :: (Show r, Show c) => IRoomsAndClients r c -> String
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   175
showRooms rnc@(IRoomsAndClients (rooms, clients)) = concatMap showRoom (allRooms rnc)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   176
    where
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   177
    showRoom r = unlines $ ((show r) ++ ": " ++ (show $ room' $ rooms ! (unRoomIndex r))) : (map showClient (roomClients' $ rooms ! (unRoomIndex r)))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   178
    showClient c = "    " ++ (show c) ++ ": " ++ (show $ client' $ clients ! (unClientIndex c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   179
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   180
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   181
allRooms :: IRoomsAndClients r c -> [RoomIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   182
allRooms (IRoomsAndClients (rooms, _)) = map RoomIndex $ indices rooms
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   183
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   184
allClients :: IRoomsAndClients r c -> [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   185
allClients (IRoomsAndClients (_, clients)) = map ClientIndex $ indices clients
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   186
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   187
clientRoom :: IRoomsAndClients r c -> ClientIndex -> RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   188
clientRoom (IRoomsAndClients (_, clients)) (ClientIndex ci) = clientRoom' (clients ! ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   189
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   190
client :: IRoomsAndClients r c -> ClientIndex -> c
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   191
client (IRoomsAndClients (_, clients)) (ClientIndex ci) = client' (clients ! ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   192
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   193
room :: IRoomsAndClients r c -> RoomIndex -> r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   194
room (IRoomsAndClients (rooms, _)) (RoomIndex ri) = room' (rooms ! ri)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   195
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   196
roomClients :: IRoomsAndClients r c -> RoomIndex -> [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   197
roomClients (IRoomsAndClients (rooms, _)) (RoomIndex ri) = roomClients' $ (rooms ! ri)