gameServer/RoomsAndClients.hs
author koda
Sat, 09 Oct 2010 18:01:47 +0200
changeset 3939 e6fddcb04dc2
parent 3901 124b4755914b
child 3947 709fdb89f76c
permissions -rw-r--r--
merge
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
    clientRoomM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    17
    clientExists,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    18
    client,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    19
    room,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    20
    client'sM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    21
    room'sM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    22
    allClientsM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    23
    clientsM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    24
    roomClientsM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    25
    roomClientsIndicesM,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    26
    withRoomsAndClients,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    27
    allRooms,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    28
    allClients,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    29
    clientRoom,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    30
    showRooms,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    31
    roomClients
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    32
    ) where
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    33
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
import Store
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    36
import Control.Monad
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    37
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
data Room r = Room {
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    40
    roomClients' :: [ClientIndex],
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    41
    room' :: r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    42
    }
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
data Client c = Client {
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    46
    clientRoom' :: RoomIndex,
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    47
    client' :: c
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    48
    }
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
newtype RoomIndex = RoomIndex ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    52
    deriving (Eq)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    53
newtype ClientIndex = ClientIndex ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    54
    deriving (Eq, Show, Read, Ord)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    55
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    56
instance Show RoomIndex where
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    57
    show (RoomIndex i) = 'r' : show i
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    58
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    59
unRoomIndex :: RoomIndex -> ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    60
unRoomIndex (RoomIndex r) = r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    61
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    62
unClientIndex :: ClientIndex -> ElemIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    63
unClientIndex (ClientIndex c) = c
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    64
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
newtype MRoomsAndClients r c = MRoomsAndClients (MStore (Room r), MStore (Client c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    67
newtype IRoomsAndClients r c = IRoomsAndClients (IStore (Room r), IStore (Client c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    68
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
lobbyId :: RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    71
lobbyId = RoomIndex firstIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    72
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
newRoomsAndClients :: r -> IO (MRoomsAndClients r c)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    75
newRoomsAndClients r = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    76
    rooms <- newStore
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    77
    clients <- newStore
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    78
    let rnc = MRoomsAndClients (rooms, clients)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    79
    ri <- addRoom rnc r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    80
    when (ri /= lobbyId) $ error "Empty struct inserts not at firstIndex index"
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    81
    return rnc
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    82
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
roomAddClient :: ClientIndex -> Room r -> Room r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    85
roomAddClient cl room = room{roomClients' = cl : roomClients' room}
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    86
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    87
roomRemoveClient :: ClientIndex -> Room r -> Room r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    88
roomRemoveClient cl room = room{roomClients' = filter (/= cl) $ roomClients' room}
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    89
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
addRoom :: MRoomsAndClients r c -> r -> IO RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    92
addRoom (MRoomsAndClients (rooms, _)) room = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    93
    i <- addElem rooms (Room  [] room)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    94
    return $ RoomIndex i
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    95
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
addClient :: MRoomsAndClients r c -> c -> IO ClientIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    98
addClient (MRoomsAndClients (rooms, clients)) client = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
    99
    i <- addElem clients (Client lobbyId client)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   100
    modifyElem rooms (roomAddClient (ClientIndex i)) (unRoomIndex lobbyId)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   101
    return $ ClientIndex i
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   102
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   103
removeRoom :: MRoomsAndClients r c -> RoomIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   104
removeRoom rnc@(MRoomsAndClients (rooms, _)) room@(RoomIndex ri) 
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   105
    | room == lobbyId = error "Cannot delete lobby"
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   106
    | otherwise = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   107
        clIds <- liftM roomClients' $ readElem rooms ri
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   108
        forM_ clIds (moveClientToLobby rnc)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   109
        removeElem rooms ri
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   110
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
removeClient :: MRoomsAndClients r c -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   113
removeClient (MRoomsAndClients (rooms, clients)) cl@(ClientIndex ci) = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   114
    RoomIndex ri <- liftM clientRoom' $ readElem clients ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   115
    modifyElem rooms (roomRemoveClient cl) ri
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   116
    removeElem clients ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   117
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
modifyRoom :: MRoomsAndClients r c -> (r -> r) -> RoomIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   120
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
   121
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   122
modifyClient :: MRoomsAndClients r c -> (c -> c) -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   123
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
   124
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   125
moveClientInRooms :: MRoomsAndClients r c -> RoomIndex -> RoomIndex -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   126
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
   127
    modifyElem rooms (roomRemoveClient cl) riFrom
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   128
    modifyElem rooms (roomAddClient cl) riTo
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   129
    modifyElem clients (\c -> c{clientRoom' = rt}) ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   130
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
moveClientToLobby :: MRoomsAndClients r c -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   133
moveClientToLobby rnc ci = do
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   134
    room <- clientRoomM rnc ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   135
    moveClientInRooms rnc room lobbyId ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   136
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
moveClientToRoom :: MRoomsAndClients r c -> RoomIndex -> ClientIndex -> IO ()
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   139
moveClientToRoom rnc ri ci = moveClientInRooms rnc lobbyId ri ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   140
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
clientExists :: MRoomsAndClients r c -> ClientIndex -> IO Bool
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   143
clientExists (MRoomsAndClients (_, clients)) (ClientIndex ci) = elemExists clients ci
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   144
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   145
clientRoomM :: MRoomsAndClients r c -> ClientIndex -> IO RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   146
clientRoomM (MRoomsAndClients (_, clients)) (ClientIndex ci) = liftM clientRoom' (clients `readElem` ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   147
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   148
client'sM :: MRoomsAndClients r c -> (c -> a) -> ClientIndex -> IO a
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   149
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
   150
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   151
room'sM :: MRoomsAndClients r c -> (r -> a) -> RoomIndex -> IO a
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   152
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
   153
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   154
allClientsM :: MRoomsAndClients r c -> IO [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   155
allClientsM (MRoomsAndClients (_, clients)) = liftM (map ClientIndex) $ indicesM clients
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   156
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   157
clientsM :: MRoomsAndClients r c -> IO [c]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   158
clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   159
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   160
roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   161
roomClientsIndicesM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   162
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   163
roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   164
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
   165
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   166
withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   167
withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   168
    withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   169
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
----------- IRoomsAndClients -----------
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   172
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   173
showRooms :: (Show r, Show c) => IRoomsAndClients r c -> String
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   174
showRooms rnc@(IRoomsAndClients (rooms, clients)) = concatMap showRoom (allRooms rnc)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   175
    where
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   176
    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
   177
    showClient c = "    " ++ (show c) ++ ": " ++ (show $ client' $ clients ! (unClientIndex c))
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   178
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
allRooms :: IRoomsAndClients r c -> [RoomIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   181
allRooms (IRoomsAndClients (rooms, _)) = map RoomIndex $ indices rooms
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   182
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   183
allClients :: IRoomsAndClients r c -> [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   184
allClients (IRoomsAndClients (_, clients)) = map ClientIndex $ indices clients
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   185
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   186
clientRoom :: IRoomsAndClients r c -> ClientIndex -> RoomIndex
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   187
clientRoom (IRoomsAndClients (_, clients)) (ClientIndex ci) = clientRoom' (clients ! ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   188
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   189
client :: IRoomsAndClients r c -> ClientIndex -> c
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   190
client (IRoomsAndClients (_, clients)) (ClientIndex ci) = client' (clients ! ci)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   191
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   192
room :: IRoomsAndClients r c -> RoomIndex -> r
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   193
room (IRoomsAndClients (rooms, _)) (RoomIndex ri) = room' (rooms ! ri)
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   194
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   195
roomClients :: IRoomsAndClients r c -> RoomIndex -> [ClientIndex]
76a197793b62 Some more that were not native
nemo
parents: 3741
diff changeset
   196
roomClients (IRoomsAndClients (rooms, _)) (RoomIndex ri) = roomClients' $ (rooms ! ri)