From 0ec910a0fb7c1e5d72e06f00806b85111138461a Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Tue, 11 Feb 2014 12:30:50 +0400 Subject: Add exchange manager and session to client session --- src/Network/BitTorrent/Client/Handle.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Network/BitTorrent/Client/Handle.hs') diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs index 467d5745..39d8393a 100644 --- a/src/Network/BitTorrent/Client/Handle.hs +++ b/src/Network/BitTorrent/Client/Handle.hs @@ -28,8 +28,9 @@ import Data.Torrent import Data.Torrent.InfoHash import Data.Torrent.Magnet import Network.BitTorrent.Client.Types -import Network.BitTorrent.DHT as DHT -import Network.BitTorrent.Tracker as Tracker +import Network.BitTorrent.DHT as DHT +import Network.BitTorrent.Exchange as Exchange +import Network.BitTorrent.Tracker as Tracker {----------------------------------------------------------------------- -- Safe handle set manupulation @@ -74,8 +75,9 @@ openTorrent :: Torrent -> BitTorrent Handle openTorrent t @ Torrent {..} = do let ih = idInfoHash tInfoDict allocHandle ih $ do - ses <- liftIO (Tracker.newSession ih (trackerList t)) - return $ Handle ih (idPrivate tInfoDict) ses + tses <- liftIO $ Tracker.newSession ih (trackerList t) + eses <- liftIO $ Exchange.newSession undefined undefined undefined + return $ Handle ih (idPrivate tInfoDict) tses eses -- | Use 'nullMagnet' to open handle from 'InfoHash'. openMagnet :: Magnet -> BitTorrent Handle @@ -105,6 +107,9 @@ start Handle {..} = do liftIO $ Tracker.notify trackerManager trackers Tracker.Started unless private $ do liftDHT $ DHT.insert topic undefined + peers <- liftIO $ askPeers trackerManager trackers + forM_ peers $ \ peer -> do + liftIO $ Exchange.insert peer exchange -- | Stop downloading this torrent. pause :: Handle -> BitTorrent () -- cgit v1.2.3