diff options
Diffstat (limited to 'src/Network/BitTorrent/Tracker.hs')
-rw-r--r-- | src/Network/BitTorrent/Tracker.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Tracker.hs b/src/Network/BitTorrent/Tracker.hs index e1f9ff76..6bf6de4b 100644 --- a/src/Network/BitTorrent/Tracker.hs +++ b/src/Network/BitTorrent/Tracker.hs | |||
@@ -164,8 +164,14 @@ getPeerList = getChanContents . sePeers | |||
164 | getProgress :: TSession -> IO Progress | 164 | getProgress :: TSession -> IO Progress |
165 | getProgress = readTVarIO . seProgress | 165 | getProgress = readTVarIO . seProgress |
166 | 166 | ||
167 | sec :: Int | ||
168 | sec = 1000 * 1000 | ||
169 | |||
167 | waitInterval :: TSession -> IO () | 170 | waitInterval :: TSession -> IO () |
168 | waitInterval = readIORef . seInterval >=> threadDelay | 171 | waitInterval se @ TSession {..} = do |
172 | delay <- readIORef seInterval | ||
173 | print delay | ||
174 | threadDelay (delay * sec) | ||
169 | 175 | ||
170 | withTracker :: Progress -> TConnection -> (TSession -> IO a) -> IO a | 176 | withTracker :: Progress -> TConnection -> (TSession -> IO a) -> IO a |
171 | withTracker initProgress conn action = bracket start end (action . fst) | 177 | withTracker initProgress conn action = bracket start end (action . fst) |
@@ -174,7 +180,7 @@ withTracker initProgress conn action = bracket start end (action . fst) | |||
174 | resp <- askTracker (startedReq conn initProgress) | 180 | resp <- askTracker (startedReq conn initProgress) |
175 | print resp | 181 | print resp |
176 | se <- newSession initProgress (respInterval resp) (respPeers resp) | 182 | se <- newSession initProgress (respInterval resp) (respPeers resp) |
177 | tid <- forkIO (syncSession se) | 183 | tid <- forkIO (return ()) -- (syncSession se) |
178 | return (se, tid) | 184 | return (se, tid) |
179 | 185 | ||
180 | syncSession se @ TSession {..} = forever $ do | 186 | syncSession se @ TSession {..} = forever $ do |
@@ -197,7 +203,8 @@ withTracker initProgress conn action = bracket start end (action . fst) | |||
197 | end (se, tid) = do | 203 | end (se, tid) = do |
198 | killThread tid | 204 | killThread tid |
199 | pr <- getProgress se | 205 | pr <- getProgress se |
200 | askTracker $ stoppedReq conn pr | 206 | print "stopping" |
207 | leaveTracker $ stoppedReq conn pr | ||
201 | 208 | ||
202 | 209 | ||
203 | 210 | ||