summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent.hs
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-06-11 04:57:56 +0400
committerSam T <pxqr.sta@gmail.com>2013-06-11 04:57:56 +0400
commit64de83063c21a963b9c7cdec82cfe2b036166c15 (patch)
tree22906f9af68e7229490537e32fb71bfdb6f23924 /src/Network/BitTorrent.hs
parentcdb75165ee0e4f2c36f5766fba4c7bc4bd31db2b (diff)
+ Add progress to client session.
Diffstat (limited to 'src/Network/BitTorrent.hs')
-rw-r--r--src/Network/BitTorrent.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs
index 5fbc5ff6..61185d08 100644
--- a/src/Network/BitTorrent.hs
+++ b/src/Network/BitTorrent.hs
@@ -5,6 +5,7 @@
5-- Stability : experimental 5-- Stability : experimental
6-- Portability : portable 6-- Portability : portable
7-- 7--
8{-# LANGUAGE RecordWildCards #-}
8module Network.BitTorrent 9module Network.BitTorrent
9 ( module BT 10 ( module BT
10 , module Data.Torrent 11 , module Data.Torrent
@@ -15,8 +16,11 @@ module Network.BitTorrent
15 , ClientSession, newClient 16 , ClientSession, newClient
16 , SwarmSession, newLeacher, newSeeder 17 , SwarmSession, newLeacher, newSeeder
17 , PeerSession 18 , PeerSession
19 , discover
18 ) where 20 ) where
19 21
22import Data.IORef
23
20import Data.Torrent 24import Data.Torrent
21import Network.BitTorrent.Internal 25import Network.BitTorrent.Internal
22import Network.BitTorrent.Extension as BT 26import Network.BitTorrent.Extension as BT
@@ -24,5 +28,12 @@ import Network.BitTorrent.Peer as BT
24import Network.BitTorrent.Exchange as BT 28import Network.BitTorrent.Exchange as BT
25import Network.BitTorrent.Tracker as BT 29import Network.BitTorrent.Tracker as BT
26 30
27--discover :: SwarmSession -> ([PeerAddr] -> IO a) -> IO a 31
28--discover = withTracker 32discover :: SwarmSession -> (TSession -> IO a) -> IO a
33discover SwarmSession {..} action = do
34 let conn = TConnection (tAnnounce torrentMeta) (tInfoHash torrentMeta)
35 (clientPeerID clientSession) port
36 progress <- readIORef (currentProgress clientSession)
37 withTracker progress conn action
38
39port = 10000