summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/Tracker/Session.hs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Tracker/Session.hs b/src/Network/BitTorrent/Tracker/Session.hs
index 9b7654dd..b5c05116 100644
--- a/src/Network/BitTorrent/Tracker/Session.hs
+++ b/src/Network/BitTorrent/Tracker/Session.hs
@@ -12,21 +12,28 @@ module Network.BitTorrent.Tracker.Session
12 Session 12 Session
13 , newSession 13 , newSession
14 , closeSession 14 , closeSession
15 , withSession
15 16
16 -- * Trackers 17 -- * Query
17 , notify 18 , Status (..)
19 , getStatus
18 , askPeers 20 , askPeers
19 21
22 -- * Events
23 , Event (..)
24 , notify
25
20 -- * Tracker Exchange 26 -- * Tracker Exchange
21 -- | BEP28: <http://www.bittorrent.org/beps/bep_0028.html> 27 -- | BEP28: <http://www.bittorrent.org/beps/bep_0028.html>
22 , addTracker 28 , addTracker
23 , removeTracker 29 , removeTracker
24 , getTrackers
25 , getTrustedTrackers 30 , getTrustedTrackers
26 ) where 31 ) where
27 32
28import Control.Applicative 33import Control.Applicative
34import Control.Exception
29import Control.Concurrent 35import Control.Concurrent
36
30import Data.Default 37import Data.Default
31import Data.Fixed 38import Data.Fixed
32import Data.Foldable 39import Data.Foldable
@@ -128,6 +135,15 @@ newSession ih origUris = do
128closeSession :: Session -> IO () 135closeSession :: Session -> IO ()
129closeSession _ = return () 136closeSession _ = return ()
130 137
138-- | Normally you need to use 'Control.Monad.Trans.Resource.alloc'.
139withSession :: InfoHash -> TrackerList URI -> (Session -> IO ()) -> IO ()
140withSession ih uris = bracket (newSession ih uris) closeSession
141
142-- | Get last announced status. The only action can alter this status
143-- is 'notify'.
144getStatus :: Session -> IO Status
145getStatus Session {..} = takeMVar currentStatus
146
131seconds :: Int -> NominalDiffTime 147seconds :: Int -> NominalDiffTime
132seconds n = realToFrac (toEnum n :: Uni) 148seconds n = realToFrac (toEnum n :: Uni)
133 149