browserglue
browserglue copied to clipboard
Message passing with local and remote peers
There should be a module that allows you to synchronize the server status (list of channels) between peers. It should be transport agnostic, so it could accept callbacks for updating local state from a remote channel (onUpdate), and for updating the state on remote peers (broadcast).
- Every channel has an owner.
- Any user can create channels and remove their own channels.
- If there is a new remote channel (i.e. another user created a channel), create the same chanel in the local browserglue instance, but without binding a port (this should be done by the local user).
bg.on(‘add-channel’, path => bg.addChannel(path));
- Only owners can remove their channels, but anyone can bind/unbind port to them, or subscribe/unsubscribe to some port in their local browserglue instance. That is, each user is responsible for assigning local ports (bind or subscribe) in their machine.
- If a user removes some channel, that channel is automatically removed from everybody else.
bg.on(‘remove-channel’, path => bg.removeChannel(path));