diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-06-28 13:49:23 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-06-28 13:49:23 +0300 |
commit | ebbffb27127b0856d4a9a59994bbf11ba9269171 (patch) | |
tree | e1d8b77c946fe1d4a252e662e13c427adaa47d84 /README.md | |
parent | a71f9a19445c026b6cea320890853ec1e58085bf (diff) |
feross's fixes to devTristan pr
explained here:
https://github.com/feross/webtorrent/pull/363#issuecomment-116253169
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -266,8 +266,7 @@ If `opts` is specified, then the default options (shown below) will be overridde rtcConfig: Object, // RTCPeerConnection configuration object (default=STUN only) storage: Function, // custom storage engine, or `false` to use in-memory engine tracker: Boolean, // Whether or not to enable trackers (default=true) - wrtc: {}, // custom webrtc implementation (in node, specify the [wrtc](https://www.npmjs.com/package/wrtc) package) - onWire: Function // function to be called on each new wire. Use this to specify [custom bittorrent extensions](https://www.npmjs.com/package/bittorrent-protocol#extension-api) + wrtc: {} // custom webrtc implementation (in node, specify the [wrtc](https://www.npmjs.com/package/wrtc) package) } ``` @@ -427,6 +426,27 @@ client.add(magnetUri, function (torrent) { }) ``` +#### `torrent.on('wire', function (wire) {})` + +Emitted whenever a new peer is connected for this torrent. `wire` is an instance of +[`bittorrent-protocol`](https://github.com/feross/bittorrent-protocol), which is a +node.js-style duplex stream to the remote peer. This event can be used to specify +[custom BitTorrent protocol extensions](https://github.com/feross/bittorrent-protocol#extension-api). + +Here is a usage example: + +```js +var MyExtension = require('./my-extension') + +torrent1.on('wire', function (wire) { + wire.use(MyExtension) +}) +``` + +See the `bittorrent-protocol` +[extension api docs](https://github.com/feross/bittorrent-protocol#extension-api) for more +information on how to define a protocol extension. + ### file api #### `file.name` |