equal
deleted
inserted
replaced
19 module HandlerUtils where |
19 module HandlerUtils where |
20 |
20 |
21 import Control.Monad.Reader |
21 import Control.Monad.Reader |
22 import qualified Data.ByteString.Char8 as B |
22 import qualified Data.ByteString.Char8 as B |
23 import Data.List |
23 import Data.List |
|
24 import Data.Word |
24 |
25 |
25 import RoomsAndClients |
26 import RoomsAndClients |
26 import CoreTypes |
27 import CoreTypes |
27 |
28 |
28 |
29 |
72 sameProtoChans = do |
73 sameProtoChans = do |
73 (ci, rnc) <- ask |
74 (ci, rnc) <- ask |
74 let p = clientProto (rnc `client` ci) |
75 let p = clientProto (rnc `client` ci) |
75 return . map sendChan . filter (\c -> clientProto c == p) . map (client rnc) $ allClients rnc |
76 return . map sendChan . filter (\c -> clientProto c == p) . map (client rnc) $ allClients rnc |
76 |
77 |
|
78 allChansProto :: Reader (ClientIndex, IRnC) [(ClientChan, Word16)] |
|
79 allChansProto = do |
|
80 (ci, rnc) <- ask |
|
81 return . map ((\c -> (sendChan c, clientProto c)) . client rnc) $ allClients rnc |
|
82 |
77 answerClient :: [B.ByteString] -> Reader (ClientIndex, IRnC) [Action] |
83 answerClient :: [B.ByteString] -> Reader (ClientIndex, IRnC) [Action] |
78 answerClient msg = liftM ((: []) . flip AnswerClients msg) thisClientChans |
84 answerClient msg = liftM ((: []) . flip AnswerClients msg) thisClientChans |
79 |
85 |
80 allRoomInfos :: Reader (a, IRnC) [RoomInfo] |
86 allRoomInfos :: Reader (a, IRnC) [RoomInfo] |
81 allRoomInfos = liftM ((\irnc -> map (room irnc) $ allRooms irnc) . snd) ask |
87 allRoomInfos = liftM ((\irnc -> map (room irnc) $ allRooms irnc) . snd) ask |