4 ms·
How do u implement the list of rooms ? Presumably, when a new room is created, this has to be broadcast to all users. Also, i guess every chat line is kind of
by yazr 8y ago
How do u implement the list of rooms ?
Presumably, when a new room is created, this has to be broadcast to all users.
Also, i guess every chat line is kind of broadcast to everyone in the room. So how do announce a new line is available?
Many thanks.
- chr15m 8y agoWhen you join a room the room name is hashed and you join a WebTorrent swarm based on that hash. So it's a collection of WebRTC peers who are connected to eachother based upon the shared hash of the room name. Not every peer is connected to every other peer. So "when a new room is created, this has to be broadcast to all users" is not quite right. A new swarm is created when a user joins a room-hash for the first time and anybody who joins that same room-hash will be introduced to the same swarm. People who have not joined the room-hash will not be part of the p2p swarm. Currently the hash-based WebRTC signalling that WebTorrent does to introduce peers is quite centralized but the actual communication channels are decentralized. The communication layer is implemented as a WebTorrent "extension protocol" extension. This is the same model dreamtime: https://github.com/chr15m/dreamtime https://github.com/chr15m/dreamtime You are correct that every chat line is broadcast to everyone in the same swarm. In fact, every message is re-broadcast multiple times redundantly by every peer who receives it for the first time, because the WebRTC swarm can be fragmented. Not every peer can directly see every other peer so we must re-broadcast everything to make sure everyone sees each line. So basically for each room you have a set of peers (browsers) connected together loosely with WebRTC data links and messages between them are sent multiple times redundantly. Thank you very much for your interest and for trying it out.