Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-12-28 23:01:31 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-12-28 23:01:31 +0300
commit697f025afac515e0a1b94ffb03474c7bec83434f (patch)
tree1c297e7196cefac08b5ea97589b714b5459d9d50
parentbff953e21aa6faa9eaea2fd0cbd4e6086a39a8ba (diff)
Add torrent.pause() API
Fix #543
-rw-r--r--README.md9
-rw-r--r--lib/torrent.js10
2 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md
index c86a3ea..edb0535 100644
--- a/README.md
+++ b/README.md
@@ -425,6 +425,15 @@ client.add(magnetUri, function (torrent) {
})
```
+#### `torrent.pause()`
+
+Temporarily stop connecting to new peers. Note that this does not pause new incoming
+connections, nor does it pause the streams of existing connections or their wires.
+
+#### `torrent.resume()`
+
+Resume connecting to new peers.
+
#### `torrent.on('done', function () {})`
Emitted when all the torrent's files have been downloaded
diff --git a/lib/torrent.js b/lib/torrent.js
index 71ee9dc..1cc4d5c 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -1205,6 +1205,16 @@ Torrent.prototype.createServer = function (opts) {
return server
}
+Torrent.prototype.pause = function () {
+ if (this.destroyed) return
+ this.swarm.pause()
+}
+
+Torrent.prototype.resume = function () {
+ if (this.destroyed) return
+ this.swarm.resume()
+}
+
Torrent.prototype._onError = function (err) {
var self = this
debug('torrent error: %s', err.message || err)