Skip to content

Commit 3485f22

Browse files
committed
update documentation for webtorrent#107
1 parent 48d1f38 commit 3485f22

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ var parsedTorrent = parseTorrent(torrent) // { infoHash: 'xxx', length: xx, anno
5858
var peerId = new Buffer('01234567890123456789')
5959
var port = 6881
6060

61+
// optional options dictionary
62+
var opts = {
63+
rtcConfig: {}, // RTCPeerConnection configuration object
64+
wrtc: {}, // custom webrtc impl (useful in node.js)
65+
getAnnounceOpts: function () {
66+
// provide a callback that will be called whenever announce() is called
67+
// internally (on timer), or by the user
68+
return {
69+
uploaded: 0,
70+
downloaded: 0,
71+
left: 0,
72+
customParam: 'blah' // custom parameters supported
73+
}
74+
}
75+
}
76+
6177
var client = new Client(peerId, port, parsedTorrent)
6278

6379
client.on('error', function (err) {
@@ -89,6 +105,14 @@ client.complete()
89105
// force a tracker announce. will trigger more 'update' events and maybe more 'peer' events
90106
client.update()
91107

108+
// provide parameters to the tracker
109+
client.update({
110+
uploaded: 0,
111+
downloaded: 0,
112+
left: 0,
113+
customParam: 'blah' // custom parameters supported
114+
})
115+
92116
// stop getting peers from the tracker, gracefully leave the swarm
93117
client.stop()
94118

client.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ inherits(Client, EventEmitter)
2121
*
2222
* Find torrent peers, to help a torrent client participate in a torrent swarm.
2323
*
24-
* @param {string|Buffer} peerId peer id
25-
* @param {Number} port torrent client listening port
26-
* @param {Object} torrent parsed torrent
27-
* @param {Object} opts options object
28-
* @param {Number} opts.rtcConfig RTCPeerConnection configuration object
29-
* @param {Number} opts.wrtc custom webrtc implementation
30-
* @param {Object} opts.getAnnounceOpts callback to provide data to tracker
24+
* @param {string|Buffer} peerId peer id
25+
* @param {Number} port torrent client listening port
26+
* @param {Object} torrent parsed torrent
27+
* @param {Object} opts options object
28+
* @param {Number} opts.rtcConfig RTCPeerConnection configuration object
29+
* @param {Number} opts.wrtc custom webrtc impl (useful in node.js)
30+
* @param {function} opts.getAnnounceOpts callback to provide data to tracker
3131
*/
3232
function Client (peerId, port, torrent, opts) {
3333
var self = this

0 commit comments

Comments
 (0)