Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

delete CR from client messages

  • Loading branch information...
commit 4cf5bdf9c219a142a43de025cdb57627708af96f 1 parent 93c6d90
@napthats authored
Showing with 8 additions and 1 deletion.
  1. +3 −1 Network/SimpleTCPServer.hs
  2. +5 −0 test.hs
View
4 Network/SimpleTCPServer.hs
@@ -20,6 +20,7 @@ import Control.Exception
import Control.Monad.Fix (fix)
import Data.IORef
import Data.List
+import Data.String.Utils (replace)
import Control.Monad
import Control.Monad.STM
import qualified Utils.Id as UI
@@ -93,7 +94,8 @@ runClient hdl wchan rchan stref = do
loop
handle (\(SomeException _) -> return ()) $ fix $ \loop -> do
line <- hGetLine hdl
- atomically $ writeTChan wchan line
+ let chomped_line = replace "\r" "" line
+ atomically $ writeTChan wchan chomped_line
loop
killThread reader
atomicModifyIORef stref (\_ -> (Dead, ()))
View
5 test.hs
@@ -282,3 +282,8 @@ tests = TestList [TestLabel "getClientMessageTest" getClientMessageTest,
TestLabel "getEachClientMessagesTest" getEachClientMessagesTest,
TestLabel "broadcastMessageTest" broadcastMessageTest,
TestLabel "sendMessageToTest" sendMessageToTest]
+
+main :: IO ()
+main = do
+ _ <- runTestTT tests
+ return ()
Please sign in to comment.
Something went wrong with that request. Please try again.