diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dhtd.hs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 9e7f4582..7d6b4046 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -1016,14 +1016,12 @@ noArgPing :: (x -> IO (Maybe r)) -> [String] -> x -> IO (Maybe r) | |||
1016 | noArgPing f [] x = f x | 1016 | noArgPing f [] x = f x |
1017 | noArgPing _ _ _ = return Nothing | 1017 | noArgPing _ _ _ = return Nothing |
1018 | 1018 | ||
1019 | -- todo: session parameter obsolete? | 1019 | -- | Create a Conduit Source by repeatedly calling an IO action. |
1020 | newXmmpSource :: (IO (Maybe Tox.CryptoMessage)) -> Tox.NetCryptoSession -> C.Source IO Tox.CryptoMessage | 1020 | ioToSource :: IO (Maybe x) -> C.Source IO x |
1021 | newXmmpSource receiveCrypto session = do | 1021 | ioToSource action = liftIO action >>= \case |
1022 | v <- liftIO receiveCrypto | 1022 | Nothing -> return () -- EOF. |
1023 | case v of | 1023 | Just item -> do C.yield item |
1024 | Nothing -> return () -- Nothing indicates EOF. | 1024 | ioToSource action |
1025 | Just cryptomessage -> do C.yield cryptomessage | ||
1026 | newXmmpSource receiveCrypto session | ||
1027 | 1025 | ||
1028 | newXmmpSink :: Tox.NetCryptoSession -> C.Sink (Flush Tox.CryptoMessage) IO () | 1026 | newXmmpSink :: Tox.NetCryptoSession -> C.Sink (Flush Tox.CryptoMessage) IO () |
1029 | newXmmpSink session@(Tox.NCrypto { ncOutgoingQueue, ncPacketQueue }) = C.awaitForever $ \flush_cyptomessage -> do | 1027 | newXmmpSink session@(Tox.NCrypto { ncOutgoingQueue, ncPacketQueue }) = C.awaitForever $ \flush_cyptomessage -> do |
@@ -1409,7 +1407,7 @@ main = runResourceT $ liftBaseWith $ \resT -> do | |||
1409 | atomically $ writeTMChan tmchan (Tox.bufferData cd) | 1407 | atomically $ writeTMChan tmchan (Tox.bufferData cd) |
1410 | return Nothing | 1408 | return Nothing |
1411 | #ifdef XMPP | 1409 | #ifdef XMPP |
1412 | xmppSrc = newXmmpSource receiveCrypto netcrypto | 1410 | xmppSrc = ioToSource receiveCrypto |
1413 | xmppSink = newXmmpSink netcrypto | 1411 | xmppSink = newXmmpSink netcrypto |
1414 | announceToxXMPPClients (xmppEventChannel sv) addrTox (Tox.ncSockAddr netcrypto) pingflag xmppSrc xmppSink | 1412 | announceToxXMPPClients (xmppEventChannel sv) addrTox (Tox.ncSockAddr netcrypto) pingflag xmppSrc xmppSink |
1415 | #endif | 1413 | #endif |