Disconnect clients on BYE message
authorunc0rr
Tue, 04 Nov 2008 22:56:36 +0000
changeset 1476 b3b28e99570f
parent 1475 bab5650fc894
child 1477 001a52a108ed
Disconnect clients on BYE message
netserver/hedgewars-server.hs
--- a/netserver/hedgewars-server.hs	Tue Nov 04 22:49:13 2008 +0000
+++ b/netserver/hedgewars-server.hs	Tue Nov 04 22:56:36 2008 +0000
@@ -57,7 +57,7 @@
 sendAnswers [] _ clients _ = return clients
 sendAnswers ((handlesFunc, answer):answers) client clients rooms = do
 	let recipients = handlesFunc client clients rooms
-	unless (null recipients) $ putStrLn ("< " ++ (show answer))
+	--unless (null recipients) $ putStrLn ("< " ++ (show answer))
 
 	clHandles' <- forM recipients $
 		\ch -> Control.Exception.handle
@@ -73,7 +73,9 @@
 			hFlush ch
 			if head answer == "BYE" then return [ch] else return []
 
-	let mclients = remove clients $ concat clHandles'
+	let outHandles = concat clHandles'
+	mapM_ (\ch -> Control.Exception.handle (const $ putStrLn "error on hClose") (hClose ch)) outHandles
+	let mclients = remove clients outHandles
 
 	sendAnswers answers client mclients rooms
 	where