equal
deleted
inserted
replaced
83 atomically $ writeTChan (chan $ fromJust $ clientByHandle ch clients) ["QUIT", show e] >> return [] -- cannot just remove |
83 atomically $ writeTChan (chan $ fromJust $ clientByHandle ch clients) ["QUIT", show e] >> return [] -- cannot just remove |
84 ) $ |
84 ) $ |
85 do |
85 do |
86 forM_ answer (\str -> hPutStrLn ch str) |
86 forM_ answer (\str -> hPutStrLn ch str) |
87 hPutStrLn ch "" |
87 hPutStrLn ch "" |
88 hFlush ch |
88 --hFlush ch |
89 if head answer == "BYE" then return [ch] else return [] |
89 if head answer == "BYE" then return [ch] else return [] |
90 |
90 |
91 let outHandles = concat clHandles' |
91 let outHandles = concat clHandles' |
92 unless (null outHandles) $ putStrLn ((show $ length outHandles) ++ " / " ++ (show $ length clients) ++ " : " ++ (show answer)) |
92 unless (null outHandles) $ putStrLn ((show $ length outHandles) ++ " / " ++ (show $ length clients) ++ " : " ++ (show answer)) |
93 mapM_ (\ch -> Control.Exception.handle (const $ putStrLn "error on hClose") (hClose ch)) outHandles |
93 |
|
94 -- strange, but this seems to be a bad idea to manually close these handles as it causes hangs |
|
95 --mapM_ (\ch -> Control.Exception.handle (const $ putStrLn "error on hClose") (hClose ch)) outHandles |
94 let mclients = remove clients outHandles |
96 let mclients = remove clients outHandles |
95 |
97 |
96 sendAnswers answers client mclients rooms |
98 sendAnswers answers client mclients rooms |
97 where |
99 where |
98 remove list rmClHandles = deleteFirstsBy2t (\ a b -> (Miscutils.handle a) == b) list rmClHandles |
100 remove list rmClHandles = deleteFirstsBy2t (\ a b -> (Miscutils.handle a) == b) list rmClHandles |