mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 20:21:36 +00:00
update documentation for #107
This commit is contained in:
parent
48d1f38e63
commit
3485f2275b
24
README.md
24
README.md
@ -58,6 +58,22 @@ var parsedTorrent = parseTorrent(torrent) // { infoHash: 'xxx', length: xx, anno
|
||||
var peerId = new Buffer('01234567890123456789')
|
||||
var port = 6881
|
||||
|
||||
// optional options dictionary
|
||||
var opts = {
|
||||
rtcConfig: {}, // RTCPeerConnection configuration object
|
||||
wrtc: {}, // custom webrtc impl (useful in node.js)
|
||||
getAnnounceOpts: function () {
|
||||
// provide a callback that will be called whenever announce() is called
|
||||
// internally (on timer), or by the user
|
||||
return {
|
||||
uploaded: 0,
|
||||
downloaded: 0,
|
||||
left: 0,
|
||||
customParam: 'blah' // custom parameters supported
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var client = new Client(peerId, port, parsedTorrent)
|
||||
|
||||
client.on('error', function (err) {
|
||||
@ -89,6 +105,14 @@ client.complete()
|
||||
// force a tracker announce. will trigger more 'update' events and maybe more 'peer' events
|
||||
client.update()
|
||||
|
||||
// provide parameters to the tracker
|
||||
client.update({
|
||||
uploaded: 0,
|
||||
downloaded: 0,
|
||||
left: 0,
|
||||
customParam: 'blah' // custom parameters supported
|
||||
})
|
||||
|
||||
// stop getting peers from the tracker, gracefully leave the swarm
|
||||
client.stop()
|
||||
|
||||
|
14
client.js
14
client.js
@ -21,13 +21,13 @@ inherits(Client, EventEmitter)
|
||||
*
|
||||
* Find torrent peers, to help a torrent client participate in a torrent swarm.
|
||||
*
|
||||
* @param {string|Buffer} peerId peer id
|
||||
* @param {Number} port torrent client listening port
|
||||
* @param {Object} torrent parsed torrent
|
||||
* @param {Object} opts options object
|
||||
* @param {Number} opts.rtcConfig RTCPeerConnection configuration object
|
||||
* @param {Number} opts.wrtc custom webrtc implementation
|
||||
* @param {Object} opts.getAnnounceOpts callback to provide data to tracker
|
||||
* @param {string|Buffer} peerId peer id
|
||||
* @param {Number} port torrent client listening port
|
||||
* @param {Object} torrent parsed torrent
|
||||
* @param {Object} opts options object
|
||||
* @param {Number} opts.rtcConfig RTCPeerConnection configuration object
|
||||
* @param {Number} opts.wrtc custom webrtc impl (useful in node.js)
|
||||
* @param {function} opts.getAnnounceOpts callback to provide data to tracker
|
||||
*/
|
||||
function Client (peerId, port, torrent, opts) {
|
||||
var self = this
|
||||
|
Loading…
Reference in New Issue
Block a user