diff --git a/README.md b/README.md index 758da3a..30a3d8b 100644 --- a/README.md +++ b/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() diff --git a/client.js b/client.js index 254a63c..650a4ca 100644 --- a/client.js +++ b/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