equal
deleted
inserted
replaced
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.Strict |
10 import Control.Monad.State.Strict |
11 import Data.Set as Set |
11 import Data.Set as Set |
12 import qualified Data.ByteString.Char8 as B |
12 import qualified Data.ByteString.Char8 as B |
|
13 import Control.DeepSeq |
13 -------------------------------------- |
14 -------------------------------------- |
14 import CoreTypes |
15 import CoreTypes |
15 import NetRoutines |
16 import NetRoutines |
16 import HWProtoCore |
17 import HWProtoCore |
17 import Actions |
18 import Actions |
26 reactCmd :: [B.ByteString] -> StateT ServerState IO () |
27 reactCmd :: [B.ByteString] -> StateT ServerState IO () |
27 reactCmd cmd = do |
28 reactCmd cmd = do |
28 (Just ci) <- gets clientIndex |
29 (Just ci) <- gets clientIndex |
29 rnc <- gets roomsClients |
30 rnc <- gets roomsClients |
30 actions <- liftIO $ withRoomsAndClients rnc (\irnc -> runReader (handleCmd cmd) (ci, irnc)) |
31 actions <- liftIO $ withRoomsAndClients rnc (\irnc -> runReader (handleCmd cmd) (ci, irnc)) |
31 forM_ actions processAction |
32 forM_ (actions `deepseq` actions) processAction |
32 |
33 |
33 mainLoop :: StateT ServerState IO () |
34 mainLoop :: StateT ServerState IO () |
34 mainLoop = forever $ do |
35 mainLoop = forever $ do |
35 get >>= \s -> put $! s |
36 get >>= \s -> put $! s |
36 |
37 |