discovery-proxy
Alows clients to use discovery-channel to discover and connect to peers.
Clients connect to the server (thos module provides a default WS implementation), search for "discovery keys", and the proxy automatically discovers and connects to peers and then proxies those connections to the client.
If two clients are discovering the same key, the proxy can connect them to each other
All discovery-proxies can make themselves discoverable so that clients can find more proxies.
Requires:
- ES6 classes
- Arrow functions
- Weak Sets (server only)
THIS IS A WORK IN PROGRESS! NOTHING TO SEE HERE.
(Dream) Example
// On a serverconst DSS = const swarm = // swarm options here // Doesn't support UTP for now const httpServer = httpServer const server = // On a clientconst DSS = const socket = 'ws://localhost:4200' const swarm = connection: socket connection swarm
Plans:
Protocol
Sent to the server
- connect
- join(discoveryKey)
- leave(discoveryKey)
Sent from the server
- streamOpen(streamID)
Sent from either end
- streamData(streamId, data)
- streamClose(streamId)
Behind the scenes
- Take a discovery-swarm instance
- When getting a new connection
- Find out how many clients want it's advertising keys
- If only one exists, proxy the connection to it
- I multiples exist, create new connections per client and proxy them
- Client side will get streams and should do handshaking on them themselves