Lobby using NGO and Lobby Services

Hello, I don’t usually post stuff but I really liked what I’ve done so I wanted to showcase the Lobby of the game I am in process of making.

The first Lobby consisted of only using Unities Lobby Services to create, join, leave, refresh and update existing Lobbies. I really didn’t like the limitations of the Lobby where there is a limit on how many times it can be updated (host/player can’t mash settings that update the map constantly) or the pooling where each player had to download the Lobby they are in and “clean” the UI and apply the values.

The first Lobby implementation looked like this:

The big downsides included:

  • Slow to update (once every second is the minimum rate).

  • Limited amount of updates before Unities Lobby System gives you notifications for too many clicks.

  • Too much data usage. Getting custom Lobby Data (packed to Binary) on every frame for every player really adds up quite fast.

So, I wanted to think of a solution on how to improve of all of those things. I came up with a solution where I would integrate Lobbies and NGO together, and so I did. The data usage decreased by quite a lot as shown in the image below (sorry for drawing on it):

As seen on the image, the amount of data usage dropped significantly. I was testing it at about the same rate as before so I was happy with my results.

The new, improved Lobby can be seen below and it shows imrovements all around. The responsivnes increased by quite a large margin (almost instantenious) and data usage decreased a lot.

The way it works is that Unities Lobby Services are only used for Lobby creation, joining and leaving of the Lobby and everything else is done using NGO. When host creates a Lobby he starts a Host and everyone joining him joins as a Client and the whole Lobby is managed through RPC’s. It only impacts people in the Lobby itself.

It increased:

  • Responsivnes - changing values, updating map, kicking players, etc, is done almost instanteniously.

  • Reduced Data Usage - since players are not “Getting” Lobby data every second the
    LobbyService.Instance.GetLobbyAsync() is barely used.

I don’t know a lot about multiplayer or Lobbies, this is my first time doing it but I am quite pleased with the results.

My UI is terrible because I am terrible at designing and drawing. There are also some bugs that need fixing , like map settings reseting each time a player joins. Thank you for your time, have a great day everyone.

1 Like

It’s a great approach. But it lacks (or i don’t know did you solve it or not) host change. The best feature of the lobby is changing the host automaticly when the host is disconnected. So how do you handle this on your way?

Also your way has one big advantage for me : members are able to write data. I tried to do a “ready” system for my lobby. I should know when the players are ready to start match. But since the members can’t write any data to lobby, i had to do in very brute way. Each time game is started, i store lobby join code at somewhere and leave the lobby (if im not the host). Until i return to main menu, i won’t join this lobby so i wouldn’t be “ready” to play next game. It seems work fine but it has only one issue, if the host is disconnected while game, the whole lobby blows up :smile:

Hmmm, I didn’t plan to add that to the game. I wanted a lobby to disband when the host leaves, I am novice in networking but I do believe changing host is still possible.

Currently, when the host leaves it forces other clients to leave the room and empties the lobby players (to disband automatically), but I believe there are ways to implement it to make other person a host (requires some trickery). Since everyone is still in the “Lobby” even thought the “Host” has stopped his network manager

  • Host leaves and the new lobby host is assigned and a single pooling event is fired for everyone, OnHostChange for example. That event holds a bool that is “isHost”.
  • Everyone receives the OnHostChange and the one that is marked with the “isHost” resets the NetworkingManager to “StartHost”.

Now, I am not sure what happens if all are running as “Client” and then one goes off and starts as “Host”. Would that work? Since my host and clients are set on unique ip that is determined by the lobbyId. I might play around to see if it would work. If it doesn’t, the simplest way would be for all the clients to stop and reconnect in a few seconds.

Now, this is for Lobby only, I am not sure if you meant how to do it in game environment. I didn’t come to that part yet but the method for the Lobby might actually work for the game environment as well. Sorry if I were of little help, pretty new to networking.

1 Like

Thanks for your reply. Yes it’s always and option to not add it. I just wonder in case you want how you can implement. Hope you can figure it out and you will post it here if you want. With that way some other users like me can benefit this. Thanks for your great work.