3458
|
1 |
module ServerState
|
|
2 |
(
|
|
3 |
module RoomsAndClients,
|
|
4 |
clientRoomA,
|
|
5 |
ServerState(..),
|
3501
|
6 |
client's,
|
|
7 |
allClientsS
|
3458
|
8 |
) where
|
|
9 |
|
|
10 |
import Control.Monad.State
|
|
11 |
----------------------
|
|
12 |
import RoomsAndClients
|
|
13 |
import CoreTypes
|
|
14 |
|
|
15 |
data ServerState = ServerState {
|
|
16 |
clientIndex :: Maybe ClientIndex,
|
|
17 |
serverInfo :: ServerInfo,
|
|
18 |
roomsClients :: MRnC
|
|
19 |
}
|
|
20 |
|
|
21 |
|
|
22 |
clientRoomA :: StateT ServerState IO RoomIndex
|
|
23 |
clientRoomA = do
|
|
24 |
(Just ci) <- gets clientIndex
|
|
25 |
rnc <- gets roomsClients
|
|
26 |
liftIO $ clientRoomM rnc ci
|
|
27 |
|
3501
|
28 |
client's :: (ClientInfo -> a) -> StateT ServerState IO a
|
|
29 |
client's f = do
|
3458
|
30 |
(Just ci) <- gets clientIndex
|
|
31 |
rnc <- gets roomsClients
|
3501
|
32 |
liftIO $ client'sM rnc f ci
|
|
33 |
|
|
34 |
allClientsS :: StateT ServerState IO [ClientInfo]
|
|
35 |
allClientsS = gets roomsClients >>= liftIO . clientsM |