netserver/hedgewars-server.hs
changeset 1468 6e6a75de2fc9
parent 1466 c68b0a0969d3
child 1469 5218aa76939e
equal deleted inserted replaced
1467:b288aea6b3d2 1468:6e6a75de2fc9
    59 sendAnswers ((handlesFunc, answer):answers) client clients rooms = do
    59 sendAnswers ((handlesFunc, answer):answers) client clients rooms = do
    60 	let recipients = handlesFunc client clients rooms
    60 	let recipients = handlesFunc client clients rooms
    61 	unless (null recipients) $ putStrLn ("< " ++ (show answer))
    61 	unless (null recipients) $ putStrLn ("< " ++ (show answer))
    62 
    62 
    63 	clHandles' <- forM recipients $
    63 	clHandles' <- forM recipients $
    64 		\ch -> Control.Exception.handle (\e -> putStrLn ("handle exception: " ++ show e) >> if head answer == "BYE" then return [ch] else atomically $ writeTChan (chan $ fromJust $ clientByHandle ch clients)  ["QUIT"] >> return []) $ -- cannot just remove
    64 		\ch -> Control.Exception.handle
       
    65 			(\e -> putStrLn ("handle exception: " ++ show e) >>
       
    66 				if head answer == "BYE" then
       
    67 					return [ch]
       
    68 				else
       
    69 					atomically $ writeTChan (chan $ fromJust $ clientByHandle ch clients) ["QUIT"] >> return []  -- cannot just remove
       
    70 			) $
    65 			do
    71 			do
    66 			forM_ answer (\str -> hPutStrLn ch str)
    72 			forM_ answer (\str -> hPutStrLn ch str)
    67 			hPutStrLn ch ""
    73 			hPutStrLn ch ""
    68 			hFlush ch
    74 			hFlush ch
    69 			if head answer == "BYE" then return [ch] else return []
    75 			if head answer == "BYE" then return [ch] else return []