DEV Community


Discussion on: Explain P2P server like I'm five!

kimberleejohnson profile image
Kimberlee Johnson

So, like you say, the server sets up the initial connection.

If you've ever been assigned a roommate at a university, for example, it's a bit like that. The university gives you your future roommate's name and phone number and maybe a bit more information about the person. From there on out, though, you don't send messages back and forth through the university, you call the roommate directly without the university being involved.

That's exactly what happens in peer to peer. Once the server has allowed me into a call, it hands me the IP addresses of others already in the call and from there I can send out my audio and video streams to each of the IPs (peers) in the call as well as receive their audio/video back. If someone else joins after me, the server lets me and the others know and we start sending/receiving media directly with the new peer. And we know how to do this because we all (or rather, our browsers all) speak the same media language, WebRTC. So the server retains knowledge about the existence of the call and who is in it, and probably has some rules about who it allows into the call, but everything else is communicated directly between the peers, never going to the server.

Does that help? The WebRTC guides and docs have helped me, so sharing here in case useful too: