gameServer/ClientIO.hs
changeset 2954 55d272e34f9a
parent 2952 18fada739b55
child 3435 4e4f88a7bdf2
equal deleted inserted replaced
2953:098eaa7fd88b 2954:55d272e34f9a
    33 clientSendLoop :: Handle -> Chan CoreMessage -> Chan [String] -> Int -> IO()
    33 clientSendLoop :: Handle -> Chan CoreMessage -> Chan [String] -> Int -> IO()
    34 clientSendLoop handle coreChan chan clientID = do
    34 clientSendLoop handle coreChan chan clientID = do
    35     answer <- readChan chan
    35     answer <- readChan chan
    36     doClose <- Exception.handle
    36     doClose <- Exception.handle
    37         (\(e :: Exception.IOException) -> if isQuit answer then return True else sendQuit e >> return False) $ do
    37         (\(e :: Exception.IOException) -> if isQuit answer then return True else sendQuit e >> return False) $ do
    38         B.hPutStrLn handle $ BUTF8.fromString $ unlines (answer ++ [""])
    38             B.hPutStrLn handle $ BUTF8.fromString $ unlines answer
    39         hFlush handle
    39             hFlush handle
    40         return $ isQuit answer
    40             return $ isQuit answer
    41 
    41 
    42     if doClose then
    42     if doClose then
    43         Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on hClose") $ hClose handle
    43         Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on hClose") $ hClose handle
    44         else
    44         else
    45         clientSendLoop handle coreChan chan clientID
    45         clientSendLoop handle coreChan chan clientID