equal
deleted
inserted
replaced
13 import RoomsAndClients |
13 import RoomsAndClients |
14 import Utils |
14 import Utils |
15 |
15 |
16 |
16 |
17 pDelim :: B.ByteString |
17 pDelim :: B.ByteString |
18 pDelim = B.pack "\n\n" |
18 pDelim = "\n\n" |
19 |
19 |
20 bs2Packets :: B.ByteString -> ([[B.ByteString]], B.ByteString) |
20 bs2Packets :: B.ByteString -> ([[B.ByteString]], B.ByteString) |
21 bs2Packets = unfoldrE extractPackets |
21 bs2Packets = unfoldrE extractPackets |
22 where |
22 where |
23 extractPackets :: B.ByteString -> Either B.ByteString ([B.ByteString], B.ByteString) |
23 extractPackets :: B.ByteString -> Either B.ByteString ([B.ByteString], B.ByteString) |
57 clientSendLoop :: Socket -> ThreadId -> Chan CoreMessage -> Chan [B.ByteString] -> ClientIndex -> IO () |
57 clientSendLoop :: Socket -> ThreadId -> Chan CoreMessage -> Chan [B.ByteString] -> ClientIndex -> IO () |
58 clientSendLoop s tId cChan chan ci = do |
58 clientSendLoop s tId cChan chan ci = do |
59 answer <- readChan chan |
59 answer <- readChan chan |
60 Exception.handle |
60 Exception.handle |
61 (\(e :: Exception.IOException) -> unless (isQuit answer) . killReciever $ show e) $ |
61 (\(e :: Exception.IOException) -> unless (isQuit answer) . killReciever $ show e) $ |
62 sendAll s $ B.unlines answer `B.append` B.singleton '\n' |
62 sendAll s $ B.unlines answer `B.snoc` '\n' |
63 |
63 |
64 if isQuit answer then |
64 if isQuit answer then |
65 do |
65 do |
66 Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on sClose") $ sClose s |
66 Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on sClose") $ sClose s |
67 killReciever . B.unpack $ quitMessage answer |
67 killReciever . B.unpack $ quitMessage answer |