Line
Link Here
|
0 |
-- hedgewars-src-0.9.9/netserver/hedgewars-server.hs |
0 |
++ hedgewars-src-0.9.9/netserver/hedgewars-server.hs |
Lines 7-13
import IO
Link Here
|
7 |
import System.IO |
7 |
import System.IO |
8 |
import Control.Concurrent |
8 |
import Control.Concurrent |
9 |
import Control.Concurrent.STM |
9 |
import Control.Concurrent.STM |
10 |
import Control.Exception (handle, finally, Exception, IOException) |
10 |
import Control.OldException (handle, finally, Exception, IOException) |
11 |
import Control.Monad |
11 |
import Control.Monad |
12 |
import Maybe (fromMaybe, isJust, fromJust) |
12 |
import Maybe (fromMaybe, isJust, fromJust) |
13 |
import Data.List |
13 |
import Data.List |
Lines 39-45
timerLoop messagesChan = forever $ do
Link Here
|
39 |
|
39 |
|
40 |
acceptLoop :: Socket -> TChan ClientInfo -> IO () |
40 |
acceptLoop :: Socket -> TChan ClientInfo -> IO () |
41 |
acceptLoop servSock acceptChan = |
41 |
acceptLoop servSock acceptChan = |
42 |
Control.Exception.handle (\(_ :: Exception) -> putStrLn "exception on connect" >> acceptLoop servSock acceptChan) $ |
42 |
Control.OldException.handle (\(_ :: Exception) -> putStrLn "exception on connect" >> acceptLoop servSock acceptChan) $ |
43 |
do |
43 |
do |
44 |
(cHandle, host, _) <- accept servSock |
44 |
(cHandle, host, _) <- accept servSock |
45 |
|
45 |
|
Lines 89-95
clientRecvLoop handle chan =
Link Here
|
89 |
clientSendLoop :: Handle -> TChan[String] -> TChan[String] -> IO() |
89 |
clientSendLoop :: Handle -> TChan[String] -> TChan[String] -> IO() |
90 |
clientSendLoop handle clChan chan = do |
90 |
clientSendLoop handle clChan chan = do |
91 |
answer <- atomically $ readTChan chan |
91 |
answer <- atomically $ readTChan chan |
92 |
doClose <- Control.Exception.handle |
92 |
doClose <- Control.OldException.handle |
93 |
(\(e :: Exception) -> if isQuit answer then return True else sendQuit e >> return False) $ do |
93 |
(\(e :: Exception) -> if isQuit answer then return True else sendQuit e >> return False) $ do |
94 |
forM_ answer (\str -> hPutStrLn handle str) |
94 |
forM_ answer (\str -> hPutStrLn handle str) |
95 |
hPutStrLn handle "" |
95 |
hPutStrLn handle "" |
Lines 97-103
clientSendLoop handle clChan chan = do
Link Here
|
97 |
return $ isQuit answer |
97 |
return $ isQuit answer |
98 |
|
98 |
|
99 |
if doClose then |
99 |
if doClose then |
100 |
Control.Exception.handle (\(_ :: Exception) -> putStrLn "error on hClose") $ hClose handle |
100 |
Control.OldException.handle (\(_ :: Exception) -> putStrLn "error on hClose") $ hClose handle |
101 |
else |
101 |
else |
102 |
clientSendLoop handle clChan chan |
102 |
clientSendLoop handle clChan chan |