3 import Control.Concurrent.STM |
3 import Control.Concurrent.STM |
4 import Control.Concurrent.Chan |
4 import Control.Concurrent.Chan |
5 import Data.IntMap |
5 import Data.IntMap |
6 import qualified Data.IntSet as IntSet |
6 import qualified Data.IntSet as IntSet |
7 import qualified Data.Sequence as Seq |
7 import qualified Data.Sequence as Seq |
|
8 import System.Log.Logger |
8 import Monad |
9 import Monad |
9 ----------------------------- |
10 ----------------------------- |
10 import CoreTypes |
11 import CoreTypes |
11 import Utils |
12 import Utils |
12 |
13 |
27 | ByeClient String |
28 | ByeClient String |
28 | ModifyClient (ClientInfo -> ClientInfo) |
29 | ModifyClient (ClientInfo -> ClientInfo) |
29 | ModifyRoom (RoomInfo -> RoomInfo) |
30 | ModifyRoom (RoomInfo -> RoomInfo) |
30 | AddRoom String String |
31 | AddRoom String String |
31 | CheckRegistered |
32 | CheckRegistered |
|
33 | ProcessAccountInfo AccountInfo |
32 | Dump |
34 | Dump |
33 |
35 |
34 type CmdHandler = Int -> Clients -> Rooms -> [String] -> [Action] |
36 type CmdHandler = Int -> Clients -> Rooms -> [String] -> [Action] |
35 |
37 |
36 |
38 |
241 client = clients ! clID |
243 client = clients ! clID |
242 rmTeamMsg = toEngineMsg $ 'F' : teamName |
244 rmTeamMsg = toEngineMsg $ 'F' : teamName |
243 |
245 |
244 |
246 |
245 processAction (clID, serverInfo, clients, rooms) (CheckRegistered) = do |
247 processAction (clID, serverInfo, clients, rooms) (CheckRegistered) = do |
246 writeChan (dbQueries serverInfo) $ HasRegistered $ nick client |
248 writeChan (dbQueries serverInfo) $ CheckAccount clID (nick client) |
247 return (clID, serverInfo, clients, rooms) |
249 return (clID, serverInfo, clients, rooms) |
248 where |
250 where |
249 client = clients ! clID |
251 client = clients ! clID |
250 |
252 |
251 processAction (clID, serverInfo, clients, rooms) (Dump) = do |
253 processAction (clID, serverInfo, clients, rooms) (Dump) = do |
252 writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms] |
254 writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms] |
253 return (clID, serverInfo, clients, rooms) |
255 return (clID, serverInfo, clients, rooms) |
254 |
256 |
|
257 processAction (clID, serverInfo, clients, rooms) (ProcessAccountInfo info) = do |
|
258 case info of |
|
259 HasAccount -> do |
|
260 infoM "Clients" $ show clID ++ " has account" |
|
261 writeChan (sendChan $ clients ! clID) ["ASKPASSWORD"] |
|
262 LogonPassed -> do |
|
263 infoM "Clients" $ show clID ++ " authenticated" |
|
264 Guest -> do |
|
265 infoM "Clients" $ show clID ++ " is guest" |
|
266 return (clID, serverInfo, clients, rooms) |