Log reply only when send it
authorunc0rr
Sat, 18 Oct 2008 21:47:28 +0000
changeset 1381 e9754d1d61a9
parent 1380 f3bdfe2452f2
child 1382 b6ab9fea22fe
Log reply only when send it
netserver/HWProto.hs
netserver/hedgewars-server.hs
--- a/netserver/HWProto.hs	Sat Oct 18 17:03:38 2008 +0000
+++ b/netserver/HWProto.hs	Sat Oct 18 21:47:28 2008 +0000
@@ -15,7 +15,7 @@
 answerBadCmd = [(clientOnly, ["ERROR", "Bad command, state or incorrect parameter"])]
 answerNotMaster = [(clientOnly, ["ERROR", "You cannot configure room parameters"])]
 answerBadParam = [(clientOnly, ["ERROR", "Bad parameter"])]
-answerQuit = [(clientOnly, ["off"])]
+answerQuit = [(clientOnly, ["BYE"])]
 answerAbandoned = [(othersInRoom, ["BYE"])]
 answerQuitInform nick = [(othersInRoom, ["LEFT", nick])]
 answerNickChosen = [(clientOnly, ["ERROR", "The nick already chosen"])]
--- a/netserver/hedgewars-server.hs	Sat Oct 18 17:03:38 2008 +0000
+++ b/netserver/hedgewars-server.hs	Sat Oct 18 21:47:28 2008 +0000
@@ -6,7 +6,7 @@
 import Control.Concurrent
 import Control.Concurrent.STM
 import Control.Exception (setUncaughtExceptionHandler, handle, finally)
-import Control.Monad (forM, forM_, filterM, liftM)
+import Control.Monad (forM, forM_, filterM, liftM, unless)
 import Maybe (fromMaybe)
 import Data.List
 import Miscutils
@@ -44,11 +44,10 @@
 sendAnswers [] _ clients _ = return clients
 sendAnswers ((handlesFunc, answer):answers) client clients rooms = do
 	let recipients = handlesFunc client clients rooms
-	putStrLn ("< " ++ (show answer))
+	unless (null recipients) $ putStrLn ("< " ++ (show answer))
 
 	clHandles' <- forM recipients $
 		\ch -> Control.Exception.handle (\e -> putStrLn (show e) >> hClose ch >> return [ch]) $
-			if (not $ null answer) && (head answer == "off") then hClose ch >> return [ch] else -- probably client with exception, don't send him anything
 			do
 			forM_ answer (\str -> hPutStrLn ch str)
 			hPutStrLn ch ""