summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2018-10-03 14:37:17 -0400
committerJoe Crayne <joe@jerkface.net>2018-11-03 10:23:45 -0400
commit0c7768ba8eb62a6a74176f737a1c9c42308d5a8c (patch)
tree4c41e5cc4f6d0486466f2d74084b682c027aaf01 /examples/dhtd.hs
parent7ca3adad36ace11b523f7029fee4d43054f941ef (diff)
Use seqence number context when serializing CryptoMessage.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 6161fbb4..5bc2b87a 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -99,7 +99,7 @@ import qualified Network.Tox.DHT.Transport as Tox
99import qualified Network.Tox.DHT.Handlers as Tox 99import qualified Network.Tox.DHT.Handlers as Tox
100import qualified Network.Tox.Onion.Transport as Tox 100import qualified Network.Tox.Onion.Transport as Tox
101import qualified Network.Tox.Onion.Handlers as Tox 101import qualified Network.Tox.Onion.Handlers as Tox
102import qualified Network.Tox.Crypto.Transport as Tox (CryptoMessage(..)) 102import qualified Network.Tox.Crypto.Transport as Tox (CryptoMessage(..),putCryptoMessage,getCryptoMessage)
103import qualified Network.Tox.Crypto.Handlers as Tox 103import qualified Network.Tox.Crypto.Handlers as Tox
104import Data.Typeable 104import Data.Typeable
105import Network.Tox.ContactInfo as Tox 105import Network.Tox.ContactInfo as Tox
@@ -1407,7 +1407,7 @@ netcrypto (Just (DHT {..})) (Just mypubkey) h roster (Just tox) exes paramStr =
1407 when (them /= their_pub) $ do 1407 when (them /= their_pub) $ do
1408 atomically $ writeTVar whoAreThey their_pub 1408 atomically $ writeTVar whoAreThey their_pub
1409 B.hPutStr myWrite ("\NUL\SOH" `B.append` S.encode (Tox.key2id their_pub)) 1409 B.hPutStr myWrite ("\NUL\SOH" `B.append` S.encode (Tox.key2id their_pub))
1410 B.hPutStr myWrite (S.encode msg) 1410 B.hPutStr myWrite (S.runPut $ Tox.putCryptoMessage 0 msg)
1411 return (Just id) 1411 return (Just id)
1412 addHooks currentHooks typs = forM_ typs $ \typ -> modifyTVar (Tox.ncHooks session) (Map.insert typ (currentHooks typ ++ [makeHook session typ])) 1412 addHooks currentHooks typs = forM_ typs $ \typ -> modifyTVar (Tox.ncHooks session) (Map.insert typ (currentHooks typ ++ [makeHook session typ]))
1413 case ranges of 1413 case ranges of
@@ -1426,7 +1426,7 @@ netcrypto (Just (DHT {..})) (Just mypubkey) h roster (Just tox) exes paramStr =
1426 tid <- myThreadId 1426 tid <- myThreadId
1427 let sidStr = printf "(%x)" (Tox.ncSessionId session) 1427 let sidStr = printf "(%x)" (Tox.ncSessionId session)
1428 labelThread tid (exekey ++ ".forward" ++ sidStr) 1428 labelThread tid (exekey ++ ".forward" ++ sidStr)
1429 let myconduit = Conduit.sourceHandle myRead .| conduitGet2 S.get -- :: ConduitT i CryptoMessage IO () 1429 let myconduit = Conduit.sourceHandle myRead .| conduitGet2 (Tox.getCryptoMessage 0) -- :: ConduitT i CryptoMessage IO ()
1430 Conduit.runConduit (myconduit .| awaitForever (\msg -> do 1430 Conduit.runConduit (myconduit .| awaitForever (\msg -> do
1431 let typ = toWord64 (getMessageType msg) 1431 let typ = toWord64 (getMessageType msg)
1432 mbSendIt <- liftIO $ atomically (lookupInRangeMap typ (Tox.ncOutHooks session)) 1432 mbSendIt <- liftIO $ atomically (lookupInRangeMap typ (Tox.ncOutHooks session))