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