1804
|
1 |
module HWProtoCore where
|
|
2 |
|
|
3 |
import qualified Data.IntMap as IntMap
|
|
4 |
--------------------------------------
|
|
5 |
import CoreTypes
|
|
6 |
import Actions
|
|
7 |
import Utils
|
|
8 |
import HWProtoNEState
|
|
9 |
import HWProtoLobbyState
|
|
10 |
import HWProtoInRoomState
|
|
11 |
|
|
12 |
handleCmd:: CmdHandler
|
|
13 |
|
|
14 |
handleCmd clID _ _ ["PING"] = [AnswerThisClient ["PONG"]]
|
|
15 |
|
|
16 |
handleCmd clID clients _ ("QUIT" : xs) =
|
|
17 |
(if isMaster client then [RemoveRoom] else [])
|
|
18 |
++ [ByeClient msg]
|
|
19 |
where
|
|
20 |
client = clients IntMap.! clID
|
|
21 |
clientNick = nick client
|
|
22 |
msg = if not $ null xs then head xs else ""
|
|
23 |
|
|
24 |
|
|
25 |
handleCmd clID clients rooms cmd =
|
|
26 |
if null (nick client) || clientProto client == 0 then
|
|
27 |
handleCmd_NotEntered clID clients rooms cmd
|
|
28 |
else if roomID client == 0 then
|
|
29 |
handleCmd_lobby clID clients rooms cmd
|
|
30 |
else
|
|
31 |
handleCmd_inRoom clID clients rooms cmd
|
|
32 |
where
|
|
33 |
client = clients IntMap.! clID
|
|
34 |
|