gameServer/OfficialServer/checker.hs
changeset 8521 80229928563f
parent 8517 648bb1cb7ebc
child 9135 151c8e553de2
--- a/gameServer/OfficialServer/checker.hs	Wed Feb 20 22:54:16 2013 +0400
+++ b/gameServer/OfficialServer/checker.hs	Wed Feb 20 23:57:01 2013 +0400
@@ -32,10 +32,22 @@
 serverAddress = "netserver.hedgewars.org"
 protocolNumber = "43"
 
+getLines :: Handle -> IO [String]
+getLines h = g
+    where
+        g = do
+            l <- liftM Just (hGetLine h) `Exception.catch` (\(_ :: Exception.IOException) -> return Nothing)
+            if isNothing l then
+                return []
+                else
+                do
+                lst <- g
+                return $ fromJust l : lst
+
 
 engineListener :: Chan Message -> Handle -> IO ()
 engineListener coreChan h = do
-    output <- liftM lines $ hGetContents h
+    output <- getLines h
     debugM "Engine" $ show output
     if isNothing $ L.find start output then
         writeChan coreChan $ CheckFailed "No stats msg"