From b5a3c7b92e7effcd234037241b00f9f29773d870 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Sat, 14 Dec 2019 01:03:07 -0500 Subject: STM-based awaitMessage. --- dht/src/Network/Tox.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'dht/src/Network/Tox.hs') 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 addVerbosity :: Transport err SockAddr ByteString -> Transport err SockAddr ByteString addVerbosity tr = tr { awaitMessage = \kont -> awaitMessage tr $ \m -> do - forM_ m $ mapM_ $ \(msg,addr) -> do + case m of + Arrival addr msg -> do when (not (B.null msg || elem (B.head msg) [0,1,2,4,0x81,0x82,0x8c,0x8d])) $ do mapM_ (\x -> dput XMisc ( (show addr) ++ " --> " ++ x)) $ xxd 0 msg + _ -> return () kont m , sendMessage = \addr msg -> do when (not (B.null msg || elem (B.head msg) [0,1,2,4,0x81,0x8c,0x8d])) $ do -- cgit v1.2.3