Skip to content

Instantly share code, notes, and snippets.

@paulkernfeld
Last active January 29, 2016 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulkernfeld/8098a2ab2d5cf0cd4dc0 to your computer and use it in GitHub Desktop.
Save paulkernfeld/8098a2ab2d5cf0cd4dc0 to your computer and use it in GitHub Desktop.
Exchanging signaling info over WebRTC

Original description:

Basically it would work like a PEX message in BitTorrent except it would work with the 2 way handshake WebRTC requires.

Considering something like this

  1. Peer A and B are connected to each other
  2. Peer A in addition know about peer C
  3. Peer A sends an extension message to B saying he knows about C
  4. Peer B replies with signalling data which A forwards to C.
  5. Peer C replies back with the other part of the signalling handshake that A forwards back to B
  6. B and C are now directly connected using no centralised servers :)

My question is, what would be a good way to present this as an interface to the end user? It seems like the right interface might differ greatly depending on the appplication, e.g. whether the nodes are in a DHT or a mesh. My idea right now is a layer on top of webrtc-swarm that makes the swarm act like a signalhub.

@paulkernfeld
Copy link
Author

@mafintosh here is a possible building block for a swarm-based signaling system. The idea is to make a webrtc-swarm present the same interface as a signalhub. That way, discovery information could be shared across the swarm.

@mafintosh
Copy link

re interface. i think it would be fun to experiment with this using the new hypercore extension protocool

var webrtcSignals = extension(core)

webrtcSignals.on('peer', function (id, peer) {
   // peer is a new stream
})
webrtcSignals.findPeers(id)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment