mafintosh / webrtc-swarm

Create a swarm of p2p connections using webrtc and a signalhub
MIT License
380 stars 60 forks source link

Can browser tabs act as signaling servers? #12

Closed lmatteis closed 8 years ago

lmatteis commented 8 years ago

With webrtc there needs to be a signaling server that both A and B know about in order to shake hands and connect to each other. I'm wonder whether C can be introduced to A via B, and not via the signaling server.

RangerMauve commented 8 years ago

Are all the tabs on the same origin in your scenario?

RangerMauve commented 8 years ago

If the tabs are all on the same origin, then you could use localStorage paired with storage events. If they are on different origins, then you'll probably want to make a hidden iframe from both that points to the same origin, then relay events between them by using postMessage for talking to the iframes, and using the storage event within the iframes to communicate between them. But at that point, why bother with webrtc?

perguth commented 8 years ago

@lmatteis Given your structure:

   B
  / \
 A   C

B can act as an intermediary and forward the signaling data. See eg. https://github.com/cjb/serverless-webrtc for a manual example of the process.

Mafintosh even wants to write module for that purpose: https://github.com/mafintosh/todo/issues/1