netserver/HWProto.hs
changeset 898 344ba7dba23d
parent 897 35d91fa3753b
child 899 36f91881e83f
equal deleted inserted replaced
897:35d91fa3753b 898:344ba7dba23d
    69 -- 'inRoom' clients state command handlers
    69 -- 'inRoom' clients state command handlers
    70 handleCmd_inRoom :: ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> (ClientInfo, [RoomInfo], [ClientInfo], [String])
    70 handleCmd_inRoom :: ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> (ClientInfo, [RoomInfo], [ClientInfo], [String])
    71 
    71 
    72 handleCmd_inRoom client _ rooms _ = (client, rooms, [client], ["ERROR", "Bad command or incorrect parameter"])
    72 handleCmd_inRoom client _ rooms _ = (client, rooms, [client], ["ERROR", "Bad command or incorrect parameter"])
    73 
    73 
    74 -- state-independent comman handlers	
    74 -- state-independent command handlers
    75 handleCmd :: ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> (ClientInfo, [RoomInfo], [ClientInfo], [String])
    75 handleCmd :: ClientInfo -> [ClientInfo] -> [RoomInfo] -> [String] -> (ClientInfo, [RoomInfo], [ClientInfo], [String])
    76 
    76 
    77 handleCmd client clients rooms ("QUIT":xs) =
    77 handleCmd client clients rooms ("QUIT":xs) =
    78 	if null (room client) then
    78 	if null (room client) then
    79 		(client, rooms, [client], ["QUIT"])
    79 		(client, rooms, [client], ["QUIT"])
       
    80 	else if isMaster client then
       
    81 		(client, filter (\rm -> room client /= name rm) rooms, fromRoom (room client) clients, ["ROOMABANDONED"])
    80 	else
    82 	else
    81 		(client, rooms, fromRoom (room client) clients, ["QUIT", nick client])
    83 		(client, rooms, fromRoom (room client) clients, ["QUIT", nick client])
    82 
    84 
    83 -- check state and call state-dependent commmand handlers
    85 -- check state and call state-dependent commmand handlers
    84 handleCmd client clients rooms cmd =
    86 handleCmd client clients rooms cmd =