From 920dd0a8eb40ec65f794fd6480835a14066d8a99 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 12 Feb 2014 19:00:33 +0400 Subject: Initialize exchange session fields --- src/Network/BitTorrent/Client/Handle.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 39d8393a..7aaaf5aa 100644 --- a/src/Network/BitTorrent/Client/Handle.hs +++ b/src/Network/BitTorrent/Client/Handle.hs @@ -71,12 +71,13 @@ lookupHandle ih = do -- | Open a torrent in 'stop'ed state. Use 'nullTorrent' to open -- handle from 'InfoDict'. This operation do not block. -openTorrent :: Torrent -> BitTorrent Handle -openTorrent t @ Torrent {..} = do +openTorrent :: FilePath -> Torrent -> BitTorrent Handle +openTorrent rootPath t @ Torrent {..} = do let ih = idInfoHash tInfoDict allocHandle ih $ do + c @ Client {..} <- getClient tses <- liftIO $ Tracker.newSession ih (trackerList t) - eses <- liftIO $ Exchange.newSession undefined undefined undefined + eses <- liftIO $ Exchange.newSession (externalAddr c) rootPath tInfoDict return $ Handle ih (idPrivate tInfoDict) tses eses -- | Use 'nullMagnet' to open handle from 'InfoHash'. @@ -91,6 +92,7 @@ closeHandle :: Handle -> BitTorrent () closeHandle h @ Handle {..} = do freeHandle topic $ do stop h + liftIO $ Exchange.closeSession exchange liftIO $ Tracker.closeSession trackers {----------------------------------------------------------------------- -- cgit v1.2.3