gameServer/ClientIO.hs
changeset 3673 45778b16b224
parent 3671 a94d1dc4a8d9
child 3947 709fdb89f76c
--- a/gameServer/ClientIO.hs	Sun Jul 25 18:55:54 2010 +0400
+++ b/gameServer/ClientIO.hs	Sun Jul 25 22:39:59 2010 +0400
@@ -60,17 +60,17 @@
 clientSendLoop :: Socket -> Chan CoreMessage -> Chan [B.ByteString] -> ClientIndex -> IO()
 clientSendLoop s coreChan chan ci = do
     answer <- readChan chan
-    doClose <- Exception.handle
-        (\(e :: Exception.IOException) -> if isQuit answer then return True else sendQuit e >> return True) $ do
+    Exception.handle
+        (\(e :: Exception.IOException) -> when (not $ isQuit answer) $ sendQuit e) $ do
             sendAll s $ (B.unlines answer) `B.append` (B.singleton '\n')
-            return $ isQuit answer
 
-    if doClose then
+    if (isQuit answer) then
         Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on sClose") $ sClose s
         else
         clientSendLoop s coreChan chan ci
 
     where
-        sendQuit e = writeChan coreChan $ ClientMessage (ci, ["QUIT", B.pack $ show e])
+        --sendQuit e = writeChan coreChan $ ClientMessage (ci, ["QUIT", B.pack $ show e])
+        sendQuit e = putStrLn $ show e
         isQuit ("BYE":xs) = True
         isQuit _ = False