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 server 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)
The dedicated server will need a configurable address to talk to a ‘lobby server’ (Unity’s or something else) whose only job is to collect the server info from servers that choose to list to it and provide that info to the clients when they connect to ask what public servers are available. The dedicated servers will ping the service occasionally to let them know it is still up, and to update the online player count data currently connected to them and/or any server info that has changed. The lobby server/service won’t be hosting anything beyond this basic centralized recordkeeping. What I’ve read so far on Unity’s lobby service seems to be doing way more than what I’d ever really need. My alternative is probably just a simple backend webservice to receive server records when they get sent to it and send a list of server records to clients when they ask for them. (with a configurable endpoint URL in another streaming assets file. I’m not going to hardcode myself into only one lobby service choice)
The lobby service/server won’t even 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 it will then make that connection on its own.
All the samples I’ve looked at so far get into things that I feel don’t quite fit what I’m trying, I don’t need separate code-locked group rooms or friends lists (yet)… just a basic “here’s the list of public servers you can join, handle connecting to them yourself.”
I’m not up to speed on UGS but it sounds like you’ll want to handle these interactions yourself with your own server in some shape or form, or maybe with Unity’s Cloud Code? That’s assuming the servers are always running the game and players come and go as they please. A lobby is more for bringing a group of players together to join in the start of a new game session.
Indeed, the player-hosted servers need to be at least capable of always running and allowing players to come and go as they please. Whether or not they are run that way will be entirely in the hands of the player running the server.
The “dedicated servers” would create a Lobby for themselves, keep meta data updated, and heart beat it. In a Unity Multiplay hosting scenario that could be a service account flow, but this sounds like player level auth as it’s the player population providing the resources and not a fully trusted server. So I think the caveat here is you’ll need to provide code in your server binary that manages this Lobby creation flow, probably need to ensure that allows max players + 1 user who would be the anonymous authed server owner/host.
These servers would definitely not be fully trusted, as they’re intended to be released to the public and runnable by players. It’s also entirely possible for zero servers to be active. It’s also possible, via server options settings, for a player to say “I don’t want my server to be public” and the code in the server will refuse to talk to whatever listing service or lobby is used. (Clients have the option to bypass the listing service/lobby via manually entered direct connect info anyway, which is the only way these private servers will be accessible). It does not feel like I’d be able to ensure the existence of a +1 anonymous user as a host in that scenario.
I’m also facing the fact that there is probably no way to avoid a central backend service for player authentication reasons anyway. I’m planning to use Unity Authorization and/or Steam, but because the server is not fully trusted I cannot have any future publisher authentication API key within the server code at all, which means for validation purposes, for a server to know if a client is who they say they are, it will have to call out to some web service that is secure, to check on its behalf. If I have to have one for that reason I might as well have one for a server listing service as well.