diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-11 12:30:50 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-11 12:30:50 +0400 |
commit | 0ec910a0fb7c1e5d72e06f00806b85111138461a (patch) | |
tree | 396fbcac569a171d9ef0e2ffe59dbd27a7f6978f /src/Network/BitTorrent/Client/Handle.hs | |
parent | 4fef598f29cbb138e7b93c5011887c2b92a12879 (diff) |
Add exchange manager and session to client session
Diffstat (limited to 'src/Network/BitTorrent/Client/Handle.hs')
-rw-r--r-- | src/Network/BitTorrent/Client/Handle.hs | 13 |
1 files changed, 9 insertions, 4 deletions
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 | |||
28 | import Data.Torrent.InfoHash | 28 | import Data.Torrent.InfoHash |
29 | import Data.Torrent.Magnet | 29 | import Data.Torrent.Magnet |
30 | import Network.BitTorrent.Client.Types | 30 | import Network.BitTorrent.Client.Types |
31 | import Network.BitTorrent.DHT as DHT | 31 | import Network.BitTorrent.DHT as DHT |
32 | import Network.BitTorrent.Tracker as Tracker | 32 | import Network.BitTorrent.Exchange as Exchange |
33 | import Network.BitTorrent.Tracker as Tracker | ||
33 | 34 | ||
34 | {----------------------------------------------------------------------- | 35 | {----------------------------------------------------------------------- |
35 | -- Safe handle set manupulation | 36 | -- Safe handle set manupulation |
@@ -74,8 +75,9 @@ openTorrent :: Torrent -> BitTorrent Handle | |||
74 | openTorrent t @ Torrent {..} = do | 75 | openTorrent t @ Torrent {..} = do |
75 | let ih = idInfoHash tInfoDict | 76 | let ih = idInfoHash tInfoDict |
76 | allocHandle ih $ do | 77 | allocHandle ih $ do |
77 | ses <- liftIO (Tracker.newSession ih (trackerList t)) | 78 | tses <- liftIO $ Tracker.newSession ih (trackerList t) |
78 | return $ Handle ih (idPrivate tInfoDict) ses | 79 | eses <- liftIO $ Exchange.newSession undefined undefined undefined |
80 | return $ Handle ih (idPrivate tInfoDict) tses eses | ||
79 | 81 | ||
80 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. | 82 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. |
81 | openMagnet :: Magnet -> BitTorrent Handle | 83 | openMagnet :: Magnet -> BitTorrent Handle |
@@ -105,6 +107,9 @@ start Handle {..} = do | |||
105 | liftIO $ Tracker.notify trackerManager trackers Tracker.Started | 107 | liftIO $ Tracker.notify trackerManager trackers Tracker.Started |
106 | unless private $ do | 108 | unless private $ do |
107 | liftDHT $ DHT.insert topic undefined | 109 | liftDHT $ DHT.insert topic undefined |
110 | peers <- liftIO $ askPeers trackerManager trackers | ||
111 | forM_ peers $ \ peer -> do | ||
112 | liftIO $ Exchange.insert peer exchange | ||
108 | 113 | ||
109 | -- | Stop downloading this torrent. | 114 | -- | Stop downloading this torrent. |
110 | pause :: Handle -> BitTorrent () | 115 | pause :: Handle -> BitTorrent () |