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-01-26 22:12:01 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-01-26 22:12:01 +0300
commit2570b37e1f7b90ae89530c4b4fb58d90b048aa7a (patch)
treea7912ecf8a8a5d756d142da7772f6b984859cb84 /index.js
parentacad9f00197aeb593573f3fc4ae39b294bce975b (diff)
throw if add or seed after destroy
For #254
Diffstat (limited to 'index.js')
-rw-r--r--index.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/index.js b/index.js
index 6e5ee0d..6015104 100644
--- a/index.js
+++ b/index.js
@@ -42,6 +42,7 @@ function WebTorrent (opts) {
EventEmitter.call(self)
if (!debug.enabled) self.setMaxListeners(0)
+ self.destroyed = false
self.torrentPort = opts.torrentPort || 0
self.tracker = opts.tracker !== undefined ? opts.tracker : true
self.rtcConfig = opts.rtcConfig
@@ -139,6 +140,7 @@ WebTorrent.prototype.get = function (torrentId) {
WebTorrent.prototype.add =
WebTorrent.prototype.download = function (torrentId, opts, ontorrent) {
var self = this
+ if (self.destroyed) throw new Error('client is destroyed')
debug('add %s', torrentId)
if (typeof opts === 'function') {
ontorrent = opts
@@ -188,6 +190,8 @@ WebTorrent.prototype.download = function (torrentId, opts, ontorrent) {
*/
WebTorrent.prototype.seed = function (input, opts, onseed) {
var self = this
+ if (self.destroyed) throw new Error('client is destroyed')
+ debug('seed %s', input)
if (typeof opts === 'function') {
onseed = opts
opts = {}
@@ -240,6 +244,7 @@ WebTorrent.prototype.remove = function (torrentId, cb) {
*/
WebTorrent.prototype.destroy = function (cb) {
var self = this
+ self.destroyed = true
debug('destroy')
var tasks = self.torrents.map(function (torrent) {