I asked this question in the Lobby forum but further research leads me to believe Lobby is not the right solution, but Cloud Code might be.
I am working on a multiplayer client/dedicated server game using ECS/Netcode for entities, etc. But my players are intended to host the provided dedicated server builds themselves.
The multiplayer menu screen from a client is intended to show a list of all other players’ dedicated servers that are up and available to join. My dedicated servers read from a json file of server options from StreamingAssets, which contains user-defined information about the server that is intended to be published, such as server name, a short and long description, the IP/port connection info the clients will need to connect to it, the servers PVP type, whether or not you need a password to join, etc. (very reminiscent of NWN style multiplayer server selection) These servers are meant to start up with no players connected, but allow players to connect/come and go as they please.
The dedicated server will need a configurable address to talk to a ‘listing service’ (Cloud Code scripts or something else?) whose only job is to collect the server info from servers that choose to list to it, and then provide that info to the clients when they connect to the listing service to ask what public servers are available. The dedicated servers will ping the listing service occasionally to let it know it is still up, and to update the online player count (of that server) and/or any server info that has changed. The listing service won’t be hosting anything beyond this basic centralized recordkeeping. My alternative is probably just a simple backend webservice to receive server records when they get sent to it and send a list of (non-stale) server records to clients when they ask for them. (with a configurable endpoint URL in another streaming assets file. I’d rather not hardcode myself into only one listing service choice)
The listing service won’t be doing any of the client-server connections. I already have that handled through Netcode stuff already, it only needs to supply the connection data from the server the client chooses to connect to and the client will then make that connection on its own.
My main concern about Cloud Code is that it does not necessarily host persistent data? Is that correct? I would need persistent data of some kind, either live in memory (Cloud code does not just shut down after execution, because it needs to wait for dedicated server pings to maintain the centralized active list) or there needs to be a shared cloud save file only accessible by cloud code.
If Cloud code cannot support remaining active in memory to await more calls to update its records, then a shared, server-side file update system would have to be used (only writable from cloud code). For example: a dedicated server comes up and runs cloud code to write an entry on its behalf with a timestamp to a server-hosted list/save file. Another dedicated server comes up and this repeats, appending to the same save file. A dedicated server pings the cloud code and it updates its timestamp in the file and any change in the amount of players it says are currently connected to it or data that describes this server entry. A client runs a different set of cloud code which reads the list/save file and hands back all server records that have a ‘recent’ timestamp (and are thus assumed to still be online) so that the client knows what servers are available to try and connect to. Any cloud code call may take the opportunity to purge the list of server records that have timestamps too far back in the past, assuming those servers are no longer running.
Is this possible to do with cloud code?