gameServer/HWProtoCore.hs
changeset 8396 5123eac2f9d6
parent 7766 98edc0724a28
child 8401 87410ae372f6
equal deleted inserted replaced
8395:0b357c57e01c 8396:5123eac2f9d6
     2 module HWProtoCore where
     2 module HWProtoCore where
     3 
     3 
     4 import Control.Monad.Reader
     4 import Control.Monad.Reader
     5 import Data.Maybe
     5 import Data.Maybe
     6 import qualified Data.ByteString.Char8 as B
     6 import qualified Data.ByteString.Char8 as B
       
     7 import qualified Data.List as L
     7 --------------------------------------
     8 --------------------------------------
     8 import CoreTypes
     9 import CoreTypes
     9 import Actions
    10 import Actions
    10 import HWProtoNEState
    11 import HWProtoNEState
    11 import HWProtoLobbyState
    12 import HWProtoLobbyState
    29     cl <- thisClient
    30     cl <- thisClient
    30     if pingsQueue cl == 0 then
    31     if pingsQueue cl == 0 then
    31         return [ProtocolError "Protocol violation"]
    32         return [ProtocolError "Protocol violation"]
    32         else
    33         else
    33         return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})]
    34         return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})]
       
    35 
       
    36 handleCmd ("CMD" : params) =
       
    37     let c = concatMap B.words params in
       
    38         if not $ null c then
       
    39             h $ (upperCase . head $ c) : tail c
       
    40             else
       
    41             return []
       
    42     where
       
    43         h ["DELEGATE", n] = handleCmd ["DELEGATE", n]
       
    44         h c = return [Warning . B.concat . L.intersperse " " $ "Unknown cmd" : c]
    34 
    45 
    35 handleCmd cmd = do
    46 handleCmd cmd = do
    36     (ci, irnc) <- ask
    47     (ci, irnc) <- ask
    37     if logonPassed (irnc `client` ci) then
    48     if logonPassed (irnc `client` ci) then
    38         handleCmd_loggedin cmd
    49         handleCmd_loggedin cmd