summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-21 20:29:57 -0400
committerjoe <joe@jerkface.net>2018-06-21 20:29:57 -0400
commit0be7e480caa1db9aa1d8d41644254e790d865f81 (patch)
treec5d78c9c59d4d33cdf9b4192df5a29f82192595e /examples/dhtd.hs
parent1391b2d5f332dbfc1e7e7fd2b7ff725caf785994 (diff)
WIP: Deliver tox generated messages to xmpp clients.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 2b5974f1..b81e88b5 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -1375,7 +1375,8 @@ newXmmpSink session@(Tox.NCrypto { ncOutgoingQueue = outGoingQVar, ncPacketQueue
1375 1375
1376-- | Called upon a new Tox friend-connection session with a remote peer in 1376-- | Called upon a new Tox friend-connection session with a remote peer in
1377-- order to set up translating conduits that simulate a remote XMPP server. 1377-- order to set up translating conduits that simulate a remote XMPP server.
1378announceToxJabberPeer :: PublicKey -- ^ Remote tox node's long-term user key. 1378announceToxJabberPeer :: PublicKey -- ^ This node's long-term user key.
1379 -> PublicKey -- ^ Remote tox node's long-term user key.
1379 -> TChan ((ConnectionKey,SockAddr), Tcp.ConnectionEvent XML.Event) 1380 -> TChan ((ConnectionKey,SockAddr), Tcp.ConnectionEvent XML.Event)
1380 -> SockAddr -- ^ Local bind address for incoming Tox packets. 1381 -> SockAddr -- ^ Local bind address for incoming Tox packets.
1381 -> SockAddr -- ^ Remote address for this connection. 1382 -> SockAddr -- ^ Remote address for this connection.
@@ -1383,14 +1384,14 @@ announceToxJabberPeer :: PublicKey -- ^ Remote tox node's long-term user key.
1383 -> C.Source IO Tox.CryptoMessage 1384 -> C.Source IO Tox.CryptoMessage
1384 -> C.Sink (Flush Tox.CryptoMessage) IO () 1385 -> C.Sink (Flush Tox.CryptoMessage) IO ()
1385 -> IO (Maybe (Tox.NetCryptoSession -> Tox.NetCryptoSession)) 1386 -> IO (Maybe (Tox.NetCryptoSession -> Tox.NetCryptoSession))
1386announceToxJabberPeer them echan laddr saddr pingflag tsrc tsnk 1387announceToxJabberPeer me them echan laddr saddr pingflag tsrc tsnk
1387 = do 1388 = do
1388 atomically $ writeTChan echan 1389 atomically $ writeTChan echan
1389 ( (PeerKey saddr, laddr ) 1390 ( (PeerKey saddr, laddr )
1390 , Tcp.Connection pingflag xsrc xsnk ) 1391 , Tcp.Connection pingflag xsrc xsnk )
1391 return Nothing 1392 return Nothing
1392 where 1393 where
1393 xsrc = tsrc =$= toxToXmpp (T.pack $ show (Tox.key2id them) ++ ".tox") 1394 xsrc = tsrc =$= toxToXmpp laddr me (T.pack $ show (Tox.key2id them) ++ ".tox")
1394 xsnk = flushPassThrough xmppToTox =$= tsnk 1395 xsnk = flushPassThrough xmppToTox =$= tsnk
1395 1396
1396vShowMe :: Tox.ViewSnapshot -> Int -> B.ByteString 1397vShowMe :: Tox.ViewSnapshot -> Int -> B.ByteString
@@ -1783,7 +1784,7 @@ main = do
1783 xmppSink = newXmmpSink netcrypto 1784 xmppSink = newXmmpSink netcrypto
1784 forM_ msv $ \sv -> do 1785 forM_ msv $ \sv -> do
1785 let Tox.HaveDHTKey saddr = Tox.ncSockAddr netcrypto 1786 let Tox.HaveDHTKey saddr = Tox.ncSockAddr netcrypto
1786 announceToxJabberPeer (Tox.ncTheirPublicKey netcrypto) (xmppEventChannel sv) addrTox saddr pingflag xmppSrc xmppSink 1787 announceToxJabberPeer (Tox.ncMyPublicKey netcrypto) (Tox.ncTheirPublicKey netcrypto) (xmppEventChannel sv) addrTox saddr pingflag xmppSrc xmppSink
1787 forM_ mbtox $ \tox -> do 1788 forM_ mbtox $ \tox -> do
1788 let ContactInfo{accounts} = Tox.toxContactInfo tox 1789 let ContactInfo{accounts} = Tox.toxContactInfo tox
1789 mbacc <- HashMap.lookup (Tox.key2id $ Tox.ncMyPublicKey netcrypto) 1790 mbacc <- HashMap.lookup (Tox.key2id $ Tox.ncMyPublicKey netcrypto)