summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Client/Handle.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Client/Handle.hs')
-rw-r--r--src/Network/BitTorrent/Client/Handle.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs
index 39d8393a..7aaaf5aa 100644
--- a/src/Network/BitTorrent/Client/Handle.hs
+++ b/src/Network/BitTorrent/Client/Handle.hs
@@ -71,12 +71,13 @@ lookupHandle ih = do
71 71
72-- | Open a torrent in 'stop'ed state. Use 'nullTorrent' to open 72-- | Open a torrent in 'stop'ed state. Use 'nullTorrent' to open
73-- handle from 'InfoDict'. This operation do not block. 73-- handle from 'InfoDict'. This operation do not block.
74openTorrent :: Torrent -> BitTorrent Handle 74openTorrent :: FilePath -> Torrent -> BitTorrent Handle
75openTorrent t @ Torrent {..} = do 75openTorrent rootPath t @ Torrent {..} = do
76 let ih = idInfoHash tInfoDict 76 let ih = idInfoHash tInfoDict
77 allocHandle ih $ do 77 allocHandle ih $ do
78 c @ Client {..} <- getClient
78 tses <- liftIO $ Tracker.newSession ih (trackerList t) 79 tses <- liftIO $ Tracker.newSession ih (trackerList t)
79 eses <- liftIO $ Exchange.newSession undefined undefined undefined 80 eses <- liftIO $ Exchange.newSession (externalAddr c) rootPath tInfoDict
80 return $ Handle ih (idPrivate tInfoDict) tses eses 81 return $ Handle ih (idPrivate tInfoDict) tses eses
81 82
82-- | Use 'nullMagnet' to open handle from 'InfoHash'. 83-- | Use 'nullMagnet' to open handle from 'InfoHash'.
@@ -91,6 +92,7 @@ closeHandle :: Handle -> BitTorrent ()
91closeHandle h @ Handle {..} = do 92closeHandle h @ Handle {..} = do
92 freeHandle topic $ do 93 freeHandle topic $ do
93 stop h 94 stop h
95 liftIO $ Exchange.closeSession exchange
94 liftIO $ Tracker.closeSession trackers 96 liftIO $ Tracker.closeSession trackers
95 97
96{----------------------------------------------------------------------- 98{-----------------------------------------------------------------------