gameServer/Actions.hs
changeset 1923 956b6b3529bc
parent 1921 2a09f7f786a0
child 1925 ec923e56c444
equal deleted inserted replaced
1922:88cdabb51995 1923:956b6b3529bc
    16 	| AnswerAll [String]
    16 	| AnswerAll [String]
    17 	| AnswerAllOthers [String]
    17 	| AnswerAllOthers [String]
    18 	| AnswerThisRoom [String]
    18 	| AnswerThisRoom [String]
    19 	| AnswerOthersInRoom [String]
    19 	| AnswerOthersInRoom [String]
    20 	| AnswerLobby [String]
    20 	| AnswerLobby [String]
       
    21 	| SendServerMessage
    21 	| RoomAddThisClient Int -- roomID
    22 	| RoomAddThisClient Int -- roomID
    22 	| RoomRemoveThisClient
    23 	| RoomRemoveThisClient
    23 	| RemoveTeam String
    24 	| RemoveTeam String
    24 	| RemoveRoom
    25 	| RemoveRoom
    25 	| UnreadyRoomClients
    26 	| UnreadyRoomClients
    87 	where
    88 	where
    88 		roomClients = IntSet.elems $ playersIDs room
    89 		roomClients = IntSet.elems $ playersIDs room
    89 		room = rooms ! 0
    90 		room = rooms ! 0
    90 
    91 
    91 
    92 
       
    93 processAction (clID, serverInfo, clients, rooms) SendServerMessage = do
       
    94 	writeChan (sendChan $ clients ! clID) $ ["SERVER_MESSAGE", serverMessage serverInfo]
       
    95 	return (clID, serverInfo, clients, rooms)
       
    96 
       
    97 
    92 processAction (clID, serverInfo, clients, rooms) (ProtocolError msg) = do
    98 processAction (clID, serverInfo, clients, rooms) (ProtocolError msg) = do
    93 	writeChan (sendChan $ clients ! clID) ["ERROR", msg]
    99 	writeChan (sendChan $ clients ! clID) ["ERROR", msg]
    94 	return (clID, serverInfo, clients, rooms)
   100 	return (clID, serverInfo, clients, rooms)
    95 
   101 
    96 
   102 
   262 	writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms]
   268 	writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms]
   263 	return (clID, serverInfo, clients, rooms)
   269 	return (clID, serverInfo, clients, rooms)
   264 
   270 
   265 
   271 
   266 processAction (clID, serverInfo, clients, rooms) (ProcessAccountInfo info) = do
   272 processAction (clID, serverInfo, clients, rooms) (ProcessAccountInfo info) = do
       
   273 	processAction (clID, serverInfo, clients, rooms) SendServerMessage
   267 	case info of
   274 	case info of
   268 		HasAccount passwd isAdmin -> do
   275 		HasAccount passwd isAdmin -> do
   269 			infoM "Clients" $ show clID ++ " has account"
   276 			infoM "Clients" $ show clID ++ " has account"
   270 			writeChan (sendChan $ clients ! clID) ["ASKPASSWORD"]
   277 			writeChan (sendChan $ clients ! clID) ["ASKPASSWORD"]
   271 			return (clID, serverInfo, adjust (\cl -> cl{webPassword = passwd, isAdministrator = isAdmin}) clID clients, rooms)
   278 			return (clID, serverInfo, adjust (\cl -> cl{webPassword = passwd, isAdministrator = isAdmin}) clID clients, rooms)