netserver/hedgewars-server.hs
changeset 1466 c68b0a0969d3
parent 1465 08e98772235c
child 1468 6e6a75de2fc9
--- a/netserver/hedgewars-server.hs	Mon Nov 03 09:55:30 2008 +0000
+++ b/netserver/hedgewars-server.hs	Mon Nov 03 11:28:41 2008 +0000
@@ -61,12 +61,12 @@
 	unless (null recipients) $ putStrLn ("< " ++ (show answer))
 
 	clHandles' <- forM recipients $
-		\ch -> Control.Exception.handle (\e -> putStrLn ("handle exception: " ++ show e) >> if head answer == "BYE" then return [ch] else return []) $ -- cannot just remove
+		\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
 			do
 			forM_ answer (\str -> hPutStrLn ch str)
 			hPutStrLn ch ""
 			hFlush ch
-			if head answer == "BYE" then hClose ch >> return [ch] else return []
+			if head answer == "BYE" then return [ch] else return []
 
 	let mclients = remove clients $ concat clHandles'