summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-25 07:33:47 -0400
committerjoe <joe@jerkface.net>2018-06-25 16:42:20 -0400
commitd1e0191f6ea329ba2ffbc1b99fd41b5aec68765b (patch)
tree378796f0e1ed4a3914f11aec45d5e05e2bf6c011 /examples/dhtd.hs
parentfab0ea6ff17b2109b20ebffcef9262b1684203ca (diff)
Forward instant messages from XMPP clients to Tox peers.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index fefec650..e099334e 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -1982,14 +1982,22 @@ main = do
1982 xmppSink = newXmmpSink netcrypto 1982 xmppSink = newXmmpSink netcrypto
1983 forM_ msv $ \sv -> do 1983 forM_ msv $ \sv -> do
1984 let Tox.HaveDHTKey saddr = Tox.ncSockAddr netcrypto 1984 let Tox.HaveDHTKey saddr = Tox.ncSockAddr netcrypto
1985 announceToxJabberPeer (Tox.ncMyPublicKey netcrypto) (Tox.ncTheirPublicKey netcrypto) (xmppEventChannel sv) addrTox saddr pingflag xmppSrc xmppSink 1985 Tox.HaveDHTKey dkey = Tox.ncTheirDHTKey netcrypto
1986 nid = Tox.key2id dkey
1987 them = Tox.ncTheirPublicKey netcrypto
1988 me = Tox.ncMyPublicKey netcrypto
1989 announceToxJabberPeer me them (xmppEventChannel sv) addrTox saddr pingflag xmppSrc xmppSink
1986 forM_ mbtox $ \tox -> do 1990 forM_ mbtox $ \tox -> do
1987 let ContactInfo{accounts} = Tox.toxContactInfo tox 1991 let ContactInfo{accounts} = Tox.toxContactInfo tox
1988 mbacc <- HashMap.lookup (Tox.key2id $ Tox.ncMyPublicKey netcrypto) 1992 mbacc <- HashMap.lookup (Tox.key2id me)
1989 <$> atomically (readTVar accounts) 1993 <$> atomically (readTVar accounts)
1994 -- TODO: Add account if it doesn't exist?
1990 forM_ mbacc $ \acnt -> do 1995 forM_ mbacc $ \acnt -> do
1991 now <- getPOSIXTime 1996 now <- getPOSIXTime
1992 atomically $ setEstablished now (Tox.ncTheirPublicKey netcrypto) acnt 1997 forM_ (either (const Nothing) Just $ Tox.nodeInfo nid saddr)
1998 $ \ni -> do
1999 atomically $ do setEstablished now them acnt
2000 setContactAddr now them ni acnt
1993 atomically $ do 2001 atomically $ do
1994 supply <- readTVar (Tox.listenerIDSupply netCryptoSessionsState) 2002 supply <- readTVar (Tox.listenerIDSupply netCryptoSessionsState)
1995 let (listenerId,supply') = freshId supply 2003 let (listenerId,supply') = freshId supply