From 1829276dd6b68aeffbe1f5560874983fec0100b2 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 20 Mar 2014 08:59:48 +0400 Subject: Expose takeMetadata function --- src/Network/BitTorrent/Client.hs | 1 + src/Network/BitTorrent/Exchange.hs | 4 ++++ src/Network/BitTorrent/Exchange/Session.hs | 4 ++++ 3 files changed, 9 insertions(+) (limited to 'src/Network/BitTorrent') diff --git a/src/Network/BitTorrent/Client.hs b/src/Network/BitTorrent/Client.hs index bdaf12a5..b9099736 100644 --- a/src/Network/BitTorrent/Client.hs +++ b/src/Network/BitTorrent/Client.hs @@ -31,6 +31,7 @@ module Network.BitTorrent.Client , Handle , handleTopic , handleTrackers + , handleExchange -- ** Construction , TorrentSource (..) diff --git a/src/Network/BitTorrent/Exchange.hs b/src/Network/BitTorrent/Exchange.hs index 8dac3c84..015bae3d 100644 --- a/src/Network/BitTorrent/Exchange.hs +++ b/src/Network/BitTorrent/Exchange.hs @@ -21,6 +21,10 @@ module Network.BitTorrent.Exchange , newSession , closeSession + -- * Query + , waitMetadata + , takeMetadata + -- * Connections , connect ) where diff --git a/src/Network/BitTorrent/Exchange/Session.hs b/src/Network/BitTorrent/Exchange/Session.hs index 8c3d5388..32f8eabd 100644 --- a/src/Network/BitTorrent/Exchange/Session.hs +++ b/src/Network/BitTorrent/Exchange/Session.hs @@ -18,6 +18,7 @@ module Network.BitTorrent.Exchange.Session -- * Events , waitMetadata + , takeMetadata ) where import Control.Applicative @@ -355,6 +356,9 @@ sendBroadcast msg = do waitMetadata :: Session -> IO InfoDict waitMetadata Session {..} = cachedValue <$> readMVar infodict +takeMetadata :: Session -> IO (Maybe InfoDict) +takeMetadata Session {..} = fmap cachedValue <$> tryReadMVar infodict + {----------------------------------------------------------------------- -- Triggers -----------------------------------------------------------------------} -- cgit v1.2.3