equal
deleted
inserted
replaced
6 import Control.Monad |
6 import Control.Monad |
7 import qualified Data.IntMap as IntMap |
7 import qualified Data.IntMap as IntMap |
8 import System.Log.Logger |
8 import System.Log.Logger |
9 import Control.Monad.Reader |
9 import Control.Monad.Reader |
10 import Control.Monad.State |
10 import Control.Monad.State |
|
11 import qualified Data.ByteString.Char8 as B |
11 -------------------------------------- |
12 -------------------------------------- |
12 import CoreTypes |
13 import CoreTypes |
13 import NetRoutines |
14 import NetRoutines |
14 import HWProtoCore |
15 import HWProtoCore |
15 import Actions |
16 import Actions |
19 |
20 |
20 timerLoop :: Int -> Chan CoreMessage -> IO() |
21 timerLoop :: Int -> Chan CoreMessage -> IO() |
21 timerLoop tick messagesChan = threadDelay (30 * 10^6) >> writeChan messagesChan (TimerAction tick) >> timerLoop (tick + 1) messagesChan |
22 timerLoop tick messagesChan = threadDelay (30 * 10^6) >> writeChan messagesChan (TimerAction tick) >> timerLoop (tick + 1) messagesChan |
22 |
23 |
23 |
24 |
24 reactCmd :: [String] -> StateT ServerState IO () |
25 reactCmd :: [B.ByteString] -> StateT ServerState IO () |
25 reactCmd cmd = do |
26 reactCmd cmd = do |
26 (Just ci) <- gets clientIndex |
27 (Just ci) <- gets clientIndex |
27 rnc <- gets roomsClients |
28 rnc <- gets roomsClients |
28 actions <- liftIO $ withRoomsAndClients rnc (\irnc -> runReader (handleCmd cmd) (ci, irnc)) |
29 actions <- liftIO $ withRoomsAndClients rnc (\irnc -> runReader (handleCmd cmd) (ci, irnc)) |
29 forM_ actions processAction |
30 forM_ actions processAction |