netserver/hedgewars-server.hs
changeset 1394 962001cfcf48
parent 1393 6d04732abed2
child 1396 abb28dcb6d0d
equal deleted inserted replaced
1393:6d04732abed2 1394:962001cfcf48
    45 sendAnswers ((handlesFunc, answer):answers) client clients rooms = do
    45 sendAnswers ((handlesFunc, answer):answers) client clients rooms = do
    46 	let recipients = handlesFunc client clients rooms
    46 	let recipients = handlesFunc client clients rooms
    47 	unless (null recipients) $ putStrLn ("< " ++ (show answer))
    47 	unless (null recipients) $ putStrLn ("< " ++ (show answer))
    48 
    48 
    49 	clHandles' <- forM recipients $
    49 	clHandles' <- forM recipients $
    50 		\ch -> Control.Exception.handle (\e -> putStrLn ("handle exception: " ++ show e) >> return []) $ -- cannot just remove
    50 		\ch -> Control.Exception.handle (\e -> putStrLn ("handle exception: " ++ show e) >> if head answer == "BYE" then return [ch] else return []) $ -- cannot just remove
    51 			do
    51 			do
    52 			forM_ answer (\str -> hPutStrLn ch str)
    52 			forM_ answer (\str -> hPutStrLn ch str)
    53 			hPutStrLn ch ""
    53 			hPutStrLn ch ""
    54 			hFlush ch
    54 			hFlush ch
    55 			if (not $ null answer) && (head answer == "BYE") then hClose ch >> return [ch] else return []
    55 			if head answer == "BYE" then hClose ch >> return [ch] else return []
    56 
    56 
    57 	let mclients = remove clients $ concat clHandles'
    57 	let mclients = remove clients $ concat clHandles'
    58 
    58 
    59 	sendAnswers answers client mclients rooms
    59 	sendAnswers answers client mclients rooms
    60 	where
    60 	where