# HG changeset patch # User unc0rr # Date 1225711721 0 # Node ID c68b0a0969d3691c51934d280f711bc5af35c541 # Parent 08e98772235c9935b037b33647cc0ba854a4846c It seems, I finally got the solution diff -r 08e98772235c -r c68b0a0969d3 netserver/Miscutils.hs --- a/netserver/Miscutils.hs Mon Nov 03 09:55:30 2008 +0000 +++ b/netserver/Miscutils.hs Mon Nov 03 11:28:41 2008 +0000 @@ -81,6 +81,9 @@ deleteFirstsBy2t :: (a -> b -> Bool) -> [a] -> [b] -> [a] deleteFirstsBy2t eq = foldl (flip (deleteBy2t eq)) +clientByHandle :: Handle -> [ClientInfo] -> Maybe ClientInfo +clientByHandle chandle clients = find (\c -> handle c == chandle) clients + sameRoom :: HandlesSelector sameRoom client clients rooms = map handle $ filter (\ci -> room ci == room client) clients diff -r 08e98772235c -r c68b0a0969d3 netserver/hedgewars-server.hs --- a/netserver/hedgewars-server.hs Mon Nov 03 09:55:30 2008 +0000 +++ b/netserver/hedgewars-server.hs Mon Nov 03 11:28:41 2008 +0000 @@ -61,12 +61,12 @@ unless (null recipients) $ putStrLn ("< " ++ (show answer)) clHandles' <- forM recipients $ - \ch -> Control.Exception.handle (\e -> putStrLn ("handle exception: " ++ show e) >> if head answer == "BYE" then return [ch] else return []) $ -- cannot just remove + \ch -> Control.Exception.handle (\e -> putStrLn ("handle exception: " ++ show e) >> if head answer == "BYE" then return [ch] else atomically $ writeTChan (chan $ fromJust $ clientByHandle ch clients) ["QUIT"] >> return []) $ -- cannot just remove do forM_ answer (\str -> hPutStrLn ch str) hPutStrLn ch "" hFlush ch - if head answer == "BYE" then hClose ch >> return [ch] else return [] + if head answer == "BYE" then return [ch] else return [] let mclients = remove clients $ concat clHandles'