gameServer/HWProtoCore.hs
changeset 10039 58cf89284115
parent 9787 0da6ba2f1f93
child 10061 b7161f00a6ca
equal deleted inserted replaced
10038:0a5e651d494c 10039:58cf89284115
    31     if pingsQueue cl == 0 then
    31     if pingsQueue cl == 0 then
    32         return [ProtocolError "Protocol violation"]
    32         return [ProtocolError "Protocol violation"]
    33         else
    33         else
    34         return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})]
    34         return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})]
    35 
    35 
    36 handleCmd ["CMD", parameters] = do
    36 handleCmd ["CMD", parameters] = uncurry h $ extractParameters parameters
    37         let (cmd, plist) = B.break (== ' ') parameters
       
    38         let param = B.dropWhile (== ' ') plist
       
    39         h (upperCase cmd) param
       
    40     where
    37     where
    41         h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n]
    38         h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n]
    42         h "STATS" _ = handleCmd ["STATS"]
    39         h "STATS" _ = handleCmd ["STATS"]
    43         h "PART" m | not $ B.null m = handleCmd ["PART", m]
    40         h "PART" m | not $ B.null m = handleCmd ["PART", m]
    44                    | otherwise = handleCmd ["PART"]
    41                    | otherwise = handleCmd ["PART"]
    52             return [AnswerClients chans ["CHAT", "[global notice]", p] | isAdministrator cl]
    49             return [AnswerClients chans ["CHAT", "[global notice]", p] | isAdministrator cl]
    53         h "WATCH" f = return [QueryReplay f]
    50         h "WATCH" f = return [QueryReplay f]
    54         h "FIX" _ = handleCmd ["FIX"]
    51         h "FIX" _ = handleCmd ["FIX"]
    55         h "UNFIX" _ = handleCmd ["UNFIX"]
    52         h "UNFIX" _ = handleCmd ["UNFIX"]
    56         h "GREETING" msg = handleCmd ["GREETING", msg]
    53         h "GREETING" msg = handleCmd ["GREETING", msg]
       
    54         h "CALLVOTE" msg | B.null msg = handleCmd ["CALLVOTE"]
       
    55                          | otherwise = let (c, p) = extractParameters msg in
       
    56                                            if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p]
       
    57         h "VOTE" msg = handleCmd ["VOTE", upperCase msg]
    57         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, p]]
    58         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, p]]
       
    59 
       
    60         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
       
    61 
    58 
    62 
    59 handleCmd cmd = do
    63 handleCmd cmd = do
    60     (ci, irnc) <- ask
    64     (ci, irnc) <- ask
    61     let cl = irnc `client` ci
    65     let cl = irnc `client` ci
    62     if logonPassed cl then
    66     if logonPassed cl then