diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-20 08:59:48 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-20 08:59:48 +0400 |
commit | 1829276dd6b68aeffbe1f5560874983fec0100b2 (patch) | |
tree | a54eff20b0fb8c225f4f74bf383e2bbc9a0fd12b /src | |
parent | a400954d19f5a540a140c2b721b1270bf12559c7 (diff) |
Expose takeMetadata function
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent.hs | 1 | ||||
-rw-r--r-- | src/Network/BitTorrent/Client.hs | 1 | ||||
-rw-r--r-- | src/Network/BitTorrent/Exchange.hs | 4 | ||||
-rw-r--r-- | src/Network/BitTorrent/Exchange/Session.hs | 4 |
4 files changed, 10 insertions, 0 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs index 154ab63a..319e66a1 100644 --- a/src/Network/BitTorrent.hs +++ b/src/Network/BitTorrent.hs | |||
@@ -40,6 +40,7 @@ module Network.BitTorrent | |||
40 | , Handle | 40 | , Handle |
41 | , handleTopic | 41 | , handleTopic |
42 | , handleTrackers | 42 | , handleTrackers |
43 | , handleExchange | ||
43 | 44 | ||
44 | , TorrentSource(openHandle) | 45 | , TorrentSource(openHandle) |
45 | , closeHandle | 46 | , closeHandle |
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 | |||
31 | , Handle | 31 | , Handle |
32 | , handleTopic | 32 | , handleTopic |
33 | , handleTrackers | 33 | , handleTrackers |
34 | , handleExchange | ||
34 | 35 | ||
35 | -- ** Construction | 36 | -- ** Construction |
36 | , TorrentSource (..) | 37 | , 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 | |||
21 | , newSession | 21 | , newSession |
22 | , closeSession | 22 | , closeSession |
23 | 23 | ||
24 | -- * Query | ||
25 | , waitMetadata | ||
26 | , takeMetadata | ||
27 | |||
24 | -- * Connections | 28 | -- * Connections |
25 | , connect | 29 | , connect |
26 | ) where | 30 | ) 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 | |||
18 | 18 | ||
19 | -- * Events | 19 | -- * Events |
20 | , waitMetadata | 20 | , waitMetadata |
21 | , takeMetadata | ||
21 | ) where | 22 | ) where |
22 | 23 | ||
23 | import Control.Applicative | 24 | import Control.Applicative |
@@ -355,6 +356,9 @@ sendBroadcast msg = do | |||
355 | waitMetadata :: Session -> IO InfoDict | 356 | waitMetadata :: Session -> IO InfoDict |
356 | waitMetadata Session {..} = cachedValue <$> readMVar infodict | 357 | waitMetadata Session {..} = cachedValue <$> readMVar infodict |
357 | 358 | ||
359 | takeMetadata :: Session -> IO (Maybe InfoDict) | ||
360 | takeMetadata Session {..} = fmap cachedValue <$> tryReadMVar infodict | ||
361 | |||
358 | {----------------------------------------------------------------------- | 362 | {----------------------------------------------------------------------- |
359 | -- Triggers | 363 | -- Triggers |
360 | -----------------------------------------------------------------------} | 364 | -----------------------------------------------------------------------} |