equal
deleted
inserted
replaced
30 else |
30 else |
31 if B.null bsPacket then |
31 if B.null bsPacket then |
32 Left bufTail |
32 Left bufTail |
33 else |
33 else |
34 Right (B.splitWith (== '\n') bsPacket, bufTail) |
34 Right (B.splitWith (== '\n') bsPacket, bufTail) |
35 |
35 |
36 |
36 |
37 listenLoop :: Socket -> Chan CoreMessage -> ClientIndex -> IO () |
37 listenLoop :: Socket -> Chan CoreMessage -> ClientIndex -> IO () |
38 listenLoop sock chan ci = recieveWithBufferLoop B.empty |
38 listenLoop sock chan ci = recieveWithBufferLoop B.empty |
39 where |
39 where |
40 recieveWithBufferLoop recvBuf = do |
40 recieveWithBufferLoop recvBuf = do |
51 clientRecvLoop :: Socket -> Chan CoreMessage -> ClientIndex -> IO () |
51 clientRecvLoop :: Socket -> Chan CoreMessage -> ClientIndex -> IO () |
52 clientRecvLoop s chan ci = do |
52 clientRecvLoop s chan ci = do |
53 msg <- (listenLoop s chan ci >> return "Connection closed") `catch` (return . B.pack . show) |
53 msg <- (listenLoop s chan ci >> return "Connection closed") `catch` (return . B.pack . show) |
54 clientOff msg |
54 clientOff msg |
55 where |
55 where |
56 clientOff msg = writeChan chan $ ClientMessage (ci, ["QUIT", msg]) |
56 clientOff msg = mapM_ (writeChan chan) [ClientMessage (ci, ["QUIT", msg]), Remove ci] |
57 |
57 |
58 |
58 |
59 |
59 |
60 clientSendLoop :: Socket -> Chan CoreMessage -> Chan [B.ByteString] -> ClientIndex -> IO() |
60 clientSendLoop :: Socket -> Chan CoreMessage -> Chan [B.ByteString] -> ClientIndex -> IO() |
61 clientSendLoop s coreChan chan ci = do |
61 clientSendLoop s coreChan chan ci = do |