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
path: root/lib
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-02-05 10:28:33 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-02-05 10:37:39 +0400
commit9001420d6459c0ea647d5c4e294f63bf3b6d8f9e (patch)
tree4261e3f8b0b68bdedaf73e04822f4540d5ed6b96 /lib
parent3b24dd52618912b9ecf988399498695627a08cf5 (diff)
fix $ ui error
Diffstat (limited to 'lib')
-rw-r--r--lib/Torrent.js8
-rw-r--r--lib/TorrentManager.js7
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Torrent.js b/lib/Torrent.js
index b0b2599..6d047a0 100644
--- a/lib/Torrent.js
+++ b/lib/Torrent.js
@@ -35,8 +35,6 @@ function Torrent (uri, opts) {
})
this.swarm.on('wire', function (wire) {
- $('.connectedPeers span').text(this.swarm.wires.length)
-
// Send KEEP-ALIVE (every 60s) so peers will not disconnect the wire
wire.setKeepAlive(true)
@@ -153,6 +151,12 @@ function Torrent (uri, opts) {
}.bind(this))
}
+Object.defineProperty(Torrent.prototype, 'numPeers', {
+ get: function () {
+ return this.swarm.wires.length
+ }
+})
+
/**
* Add a peer to the swarm
* @param {string} addr
diff --git a/lib/TorrentManager.js b/lib/TorrentManager.js
index cac04eb..265ef26 100644
--- a/lib/TorrentManager.js
+++ b/lib/TorrentManager.js
@@ -84,5 +84,12 @@ TorrentManager.prototype.updateUI = function () {
$('.dhtNodes span').text(Object.keys(this.dht.nodes).length)
$('.dhtPeers span').text(Object.keys(this.dht.peers).length)
+
+ var connectedPeers = 0
+ for (var infoHash in this.torrents) {
+ var torrent = this.torrents[infoHash]
+ connectedPeers += torrent.numPeers
+ }
+ $('.connectedPeers span').text(connectedPeers)
}