summaryrefslogtreecommitdiff
path: root/dht/src/Network/Tox.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-12-14 01:03:07 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-01 23:26:05 -0500
commitb5a3c7b92e7effcd234037241b00f9f29773d870 (patch)
tree4047e11c9102585001dd3be95855038a6816a5c2 /dht/src/Network/Tox.hs
parent97043e1069e172a0f389610610892ca060f395dd (diff)
STM-based awaitMessage.
Diffstat (limited to 'dht/src/Network/Tox.hs')
-rw-r--r--dht/src/Network/Tox.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/dht/src/Network/Tox.hs b/dht/src/Network/Tox.hs
index 61a1d117..4b66cfc8 100644
--- a/dht/src/Network/Tox.hs
+++ b/dht/src/Network/Tox.hs
@@ -222,10 +222,12 @@ isLocalHost _ = False
222addVerbosity :: Transport err SockAddr ByteString -> Transport err SockAddr ByteString 222addVerbosity :: Transport err SockAddr ByteString -> Transport err SockAddr ByteString
223addVerbosity tr = 223addVerbosity tr =
224 tr { awaitMessage = \kont -> awaitMessage tr $ \m -> do 224 tr { awaitMessage = \kont -> awaitMessage tr $ \m -> do
225 forM_ m $ mapM_ $ \(msg,addr) -> do 225 case m of
226 Arrival addr msg -> do
226 when (not (B.null msg || elem (B.head msg) [0,1,2,4,0x81,0x82,0x8c,0x8d])) $ do 227 when (not (B.null msg || elem (B.head msg) [0,1,2,4,0x81,0x82,0x8c,0x8d])) $ do
227 mapM_ (\x -> dput XMisc ( (show addr) ++ " --> " ++ x)) 228 mapM_ (\x -> dput XMisc ( (show addr) ++ " --> " ++ x))
228 $ xxd 0 msg 229 $ xxd 0 msg
230 _ -> return ()
229 kont m 231 kont m
230 , sendMessage = \addr msg -> do 232 , sendMessage = \addr msg -> do
231 when (not (B.null msg || elem (B.head msg) [0,1,2,4,0x81,0x8c,0x8d])) $ do 233 when (not (B.null msg || elem (B.head msg) [0,1,2,4,0x81,0x8c,0x8d])) $ do