diff options
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/BitTorrent/Client/Handle.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs index d68c57cc..a1fe7b9e 100644 --- a/src/Network/BitTorrent/Client/Handle.hs +++ b/src/Network/BitTorrent/Client/Handle.hs | |||
@@ -22,6 +22,7 @@ import Control.Applicative | |||
22 | import Control.Concurrent | 22 | import Control.Concurrent |
23 | import Control.Monad | 23 | import Control.Monad |
24 | import Control.Monad.Trans | 24 | import Control.Monad.Trans |
25 | import Data.Default | ||
25 | import Data.List as L | 26 | import Data.List as L |
26 | import Data.HashMap.Strict as HM | 27 | import Data.HashMap.Strict as HM |
27 | 28 | ||
@@ -89,7 +90,18 @@ openTorrent rootPath t @ Torrent {..} = do | |||
89 | 90 | ||
90 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. | 91 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. |
91 | openMagnet :: FilePath -> Magnet -> BitTorrent Handle | 92 | openMagnet :: FilePath -> Magnet -> BitTorrent Handle |
92 | openMagnet rootPath uri @ Magnet {..} = error "openMagnet: not implemnted" | 93 | openMagnet rootPath uri @ Magnet {..} = do |
94 | allocHandle exactTopic $ do | ||
95 | c @ Client {..} <- getClient | ||
96 | tses <- liftIO $ Tracker.newSession exactTopic def | ||
97 | eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) | ||
98 | rootPath (error "openMagnet" exactTopic) | ||
99 | return $ Handle | ||
100 | { topic = exactTopic | ||
101 | , private = False | ||
102 | , trackers = tses | ||
103 | , exchange = eses | ||
104 | } | ||
93 | 105 | ||
94 | -- | Stop torrent and destroy all sessions. You don't need to close | 106 | -- | Stop torrent and destroy all sessions. You don't need to close |
95 | -- handles at application exit, all handles will be automatically | 107 | -- handles at application exit, all handles will be automatically |