gameServer/Actions.hs
changeset 10212 5fb3bb2de9d2
parent 10195 d1c23bb73346
child 10215 26fc5502ba22
equal deleted inserted replaced
10211:f4c51ab8f46d 10212:5fb3bb2de9d2
    32 import ServerState
    32 import ServerState
    33 import Consts
    33 import Consts
    34 import ConfigFile
    34 import ConfigFile
    35 import EngineInteraction
    35 import EngineInteraction
    36 import FloodDetection
    36 import FloodDetection
    37 
    37 import HWProtoCore
    38 
       
    39 type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
       
    40 
    38 
    41 
    39 
    42 othersChans :: StateT ServerState IO [ClientChan]
    40 othersChans :: StateT ServerState IO [ClientChan]
    43 othersChans = do
    41 othersChans = do
    44     cl <- client's id
    42     cl <- client's id
   796 
   794 
   797 
   795 
   798 processAction (RegisterEvent e) = do
   796 processAction (RegisterEvent e) = do
   799     actions <- registerEvent e
   797     actions <- registerEvent e
   800     mapM_ processAction actions
   798     mapM_ processAction actions
       
   799 
       
   800 
       
   801 processAction (ReactCmd cmd) = do
       
   802     (Just ci) <- gets clientIndex
       
   803     rnc <- gets roomsClients
       
   804     actions <- liftIO $ withRoomsAndClients rnc (\irnc -> runReader (handleCmd cmd) (ci, irnc))
       
   805     forM_ (actions `deepseq` actions) processAction