Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending messages to webtorrents peers #1335

Closed
Fabiencdp opened this issue Mar 19, 2018 · 1 comment
Closed

Sending messages to webtorrents peers #1335

Fabiencdp opened this issue Mar 19, 2018 · 1 comment
Labels

Comments

@Fabiencdp
Copy link

@Fabiencdp Fabiencdp commented Mar 19, 2018

Hello,
i wonder if there is a way to send custom message/data to peer who use webTorrent directly.
It work well using the simple-peer module, after doing all the signaling process i can send message with for example :

var peer = new Peer(options);
// Handle signaling process 
// ... 
peer.send("hey mate!")

and i receive it in the other browser using the "data" event.

Here is a way to do that directly with the webtorrent wires ? for example
torrent.wires[0].send("hey mate");

Thanks for your help !

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 15, 2018

You can technically reach into the wire's private simple-peer object and call send() but you'll likely confuse the remote peer who will then just disconnect.

The correct way to implement this is to use the extension API in bittorrent-protocol which will send a standard message to the remote peer which advertises support for your extension. If the remote peer also has support for your extension, then you can send custom messages to each other.

@feross feross closed this May 15, 2018
@feross feross added the question label May 15, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.