diff options
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index f25792ac..2f903d5f 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -1215,6 +1215,11 @@ announceToxJabberPeer echan laddr saddr pingflag tsrc tsnk | |||
1215 | 1215 | ||
1216 | #endif | 1216 | #endif |
1217 | 1217 | ||
1218 | data PerSession = PerSession { perSessionMsgs :: PacketQueue (Bool{-Handled?-},Tox.CryptoMessage) | ||
1219 | , perSessionPublicKey :: PublicKey | ||
1220 | , perSessionAddr :: SockAddr | ||
1221 | } | ||
1222 | |||
1218 | main :: IO () | 1223 | main :: IO () |
1219 | main = runResourceT $ liftBaseWith $ \resT -> do | 1224 | main = runResourceT $ liftBaseWith $ \resT -> do |
1220 | args <- getArgs | 1225 | args <- getArgs |
@@ -1322,6 +1327,7 @@ main = runResourceT $ liftBaseWith $ \resT -> do | |||
1322 | 1327 | ||
1323 | crypto <- Tox.newCrypto | 1328 | crypto <- Tox.newCrypto |
1324 | netCryptoSessionsState <- Tox.newSessionsState crypto Tox.defaultUnRecHook Tox.defaultCryptoDataHooks | 1329 | netCryptoSessionsState <- Tox.newSessionsState crypto Tox.defaultUnRecHook Tox.defaultCryptoDataHooks |
1330 | sessions <- atomically (newTVar []) :: IO (TVar [PerSession]) | ||
1325 | (mbtox,quitTox,toxdhts,toxips,taddrs) <- case porttox opts of | 1331 | (mbtox,quitTox,toxdhts,toxips,taddrs) <- case porttox opts of |
1326 | "" -> return (Nothing,return (), Map.empty, return [],[]) | 1332 | "" -> return (Nothing,return (), Map.empty, return [],[]) |
1327 | toxport -> do | 1333 | toxport -> do |
@@ -1544,12 +1550,12 @@ main = runResourceT $ liftBaseWith $ \resT -> do | |||
1544 | announceToxJabberPeer (xmppEventChannel sv) addrTox (Tox.ncSockAddr netcrypto) pingflag xmppSrc xmppSink | 1550 | announceToxJabberPeer (xmppEventChannel sv) addrTox (Tox.ncSockAddr netcrypto) pingflag xmppSrc xmppSink |
1545 | -- TODO: Update toxContactInfo, connected. | 1551 | -- TODO: Update toxContactInfo, connected. |
1546 | #endif | 1552 | #endif |
1547 | let handleIncoming typ session cd | any ($ typ) [Tox.isKillPacket, Tox.isOFFLINE] = atomically $ do | 1553 | let handleIncoming typ session cm | any ($ typ) [Tox.isKillPacket, Tox.isOFFLINE] = atomically $ do |
1548 | closeTMChan tmchan | 1554 | closeTMChan tmchan |
1549 | Tox.forgetCrypto crypto netCryptoSessionsState netcrypto | 1555 | Tox.forgetCrypto crypto netCryptoSessionsState netcrypto |
1550 | return Nothing | 1556 | return Nothing |
1551 | handleIncoming mTyp session cd = do | 1557 | handleIncoming mTyp session cm = do |
1552 | atomically $ writeTMChan tmchan (Tox.bufferData cd) | 1558 | atomically $ writeTMChan tmchan cm -- (Tox.bufferData cd) |
1553 | return Nothing | 1559 | return Nothing |
1554 | atomically $ writeTVar (Tox.ncUnrecognizedHook netcrypto) handleIncoming | 1560 | atomically $ writeTVar (Tox.ncUnrecognizedHook netcrypto) handleIncoming |
1555 | return Nothing | 1561 | return Nothing |