peerjs
peerjs copied to clipboard
Documentation on connections
Hi there - I'm trying to understand how peerjs works, in order to write a rust crate that supports it (of course I'd be happy to hear that such a thing already exists ;)
From what I read in the code, there are two connections set up between a client and the peerjs-server:
- one websocket connection
- one (or more?) connection for the REST-calls to offer/candidate/answer/leave
From what I understand, if node1 wants to connect to node2, they each need to be connected to the server using websockets. Then node1 makes a POST-request with an offer to the server. This request will be sent over the websocket to node2.
What I don't understand is: why do you use the REST calls at all? Couldn't you keep all the communication through the websocket?
Is there any low-level documentation other than the source code?
From what I know about the library, the REST API is only used to get a unique id and to list all peers (https://github.com/peers/peerjs/blob/master/lib/api.ts). Everything else is send over the websocket.
Yes, this is what I understood. As I'm writing my own signalling server in rust, I wondered whether there is a good reason to have two protocols instead of one. But so far it works very nice with only one protocol (websockets), so I'll keep that.
Hi, is your Rust implementation available? Would love to try it out :)
You can find it here:
https://crates.io/crates/flnet
Be sure to check out the documentation. I also have a running example here:
https://web.fledg.re