Open HerbCaudill opened 5 years ago
Currently if we see a configuration with more than one URL for signal servers, we just pick the first one.
That's because we don't currently support having more than one signal server per discovery key. (If Alice talks to signal server X and Bob talks to signal server B, they'll never be introduced even if they have the same discovery key.) That's because servers don't know anything about each other.
To support multiple signal servers, I'd like to implement a swarm along these lines:
The server starts out with a list of known servers and tries to establish a direct websocket to each.
When any two servers connect, they sync up on an Automerge document containing a directory of known servers, along with the discovery keys that each one handles, and the number of clients currently connected for each.
If the latest document contains servers that this server is not connected to, it tries to connect to each one.
The client starts out with the same list of known servers, and picks one somehow (randomly, lowest ping, etc.)
When a client connects:
randomly select a URL if more than one is provided? select best based on ping?
https://github.com/DevResults/cevitxe/blob/c8f9e8c6676987c5fed42131fd7115a22c9fd12e/packages/core/src/Client.ts#L23-L28
This comment was generated by todo based on a
TODO
comment in c8f9e8c6676987c5fed42131fd7115a22c9fd12e in #26. cc @DevResults.Originally posted by @todo in https://github.com/DevResults/cevitxe/pull/26#issuecomment-541784149