Rooms, peers and keys
App and key
Section titled “App and key”Your app has a publishable key (pk_…) and a list of allowed origins. The key is meant to be in your page source. It identifies your app and is no secret, and the service also checks the page’s origin.
A room is a name you choose: [A-Za-z0-9_-], 1 to 64 characters. Rooms belong to your app: another app’s room with the same name is a different room. A room exists while someone is in it.
Anyone who knows your key and a room name can join that room (from an allowed origin), so use names that are hard to guess. See security and privacy.
Peer id
Section titled “Peer id”The service gives each join() an integer id, unique in the room. A page reload or a new join() gets a new id. If your app has users, use join tickets: your server signs one for each user, and room.user(peerId) then gives every peer’s user id, vouched for by the service. Without tickets, map ids to users yourself: send room.id to your server after joining.
The mesh
Section titled “The mesh”Each browser keeps direct links to a few others, about 6 (4 on phones), not to everyone, and messages are forwarded hop by hop. That keeps a 30-peer room cheap for every browser. See how messages travel.