Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upA new bittorent extension (like ut_pex, ut_metadata) to send plain chat message to peer #368
Comments
This comment has been minimized.
This comment has been minimized.
torrent.on('wire', function (wire) {})https://github.com/feross/webtorrent#torrentonwire-function-wire- |
This comment has been minimized.
This comment has been minimized.
|
My Seeder looks like: var client = new WebTorrent({
dht: {
announce: ['http://127.0.0.1:6881/announce']
}
});
client.seed('something.mp4', {
announce: ['http://127.0.0.1:6881/announce'],
private: false
}, function onTorrent (torrent) {
// Client is seeding the file!
console.log('MargnetURI:', torrent.magnetURI);
console.log('Info hash:', torrent.infoHash);
});
client.on('torrent', function (torrent) {
torrent.on("wire", function(wire) {
console.log("onwire - " + wire.peerId + " - " + wire.remoteAddress + ':' + wire.remotePort);
wire.on('extended', function (ext, obj) {
console.log('extended', ext, obj.toString());
});
wire.ut_pex.on('warning', function (err) {
console.log('warning', err.message)
})
wire.extended(2, 'hello');
});
});-- The callback onwire will be called if i specify torrent.swarm.on("wire", function(wire) {instead of torrent.on("wire", function(wire) {Which one I should use ? -- When i restart the local tracker then the litcher is getting the message 'hello'. Is there anything wrong I am doing? |
This comment has been minimized.
This comment has been minimized.
|
If I were you, I'd get started using the test. https://github.com/feross/webtorrent/blob/master/test/extensions.js Provided your extension is properly named, you can then send messages like this: wire.extended('my_extension', 'ayyyy lmao') |
This comment has been minimized.
This comment has been minimized.
|
What @devtristan said – thanks for helping out! |
This comment has been minimized.
This comment has been minimized.
|
I was using webtorrent@0.49.2, that may be the reason why "torrent.on("wire", function(wire) {" was not triggering. When i updated to webtorrent@0.51.1 it starts working. Yes, @devtristan I have created a new extension for message communication and I will be using the way you suggested. Thanks both you. |
This comment has been minimized.
This comment has been minimized.
|
How is your extension working @vairabagni? You can add extensions to the list of known extensions by making a pull request here https://github.com/feross/bittorrent-protocol#extension-api I'm interested in something like this |
How can I use this extension or ut_metadata or by creating a new one to be able to send messages to other peer (chat message) ?
I just started by creating a new extension which i am thinking of integrating that into webtorrent. So I modified torrent.js (inside webtorrent, ln 463) - _onWire callback - this block is same as that of ut_pex.
Is it required? Or i can just use any extension (ut_metadata, ut_pex or mine - ut_message) as: