Lobby beacons: is the host a client?

Hi everybody!

I try to implement a lobby system with Steam in my online multiplayer game. This is what I want to do:

  • A player can create a lobby from the game menu, without any map transition
  • He can invite friends to join his lobby
  • Friends can join the lobby without map transition, and see information about lobby members (nicknames, ranking, etc.)
  • The owner of the lobby can find a match online, and every player in the lobby follows him

Here is my process:

  • I spawn a LobbyBeaconHost and I call the Init function on it
  • I call the SetupLobbyState function and call the StartLobby function on it
  • I create a Steam session, so other players can see it
  • I spawn a OnlineBeaconHost, in which I setup the BeaconState to AllowRequests
  • I start my OnlineBeaconHost with the InitHost function and I add to it the previous LobbyBeaconHost (with the AddHost function)

From what I understand, I think that my lobby is created and now accessible for other players.

So, I successfully created a lobby on a client, I can invite friends, and they can join my lobby.
The thing I don’t understand is when I check the GetNumPlayers() function in my LobbyState: when I’m alone in the lobby, it returns 0, and not 1, as I first expected. If a friend joins me, the function returns 1.

So my question is: does the owner of the lobby beacon have to connect to his own lobby?
If this is the case, how can I do this? I tried it by calling the ConnectToLobby function in the LobbyBeaconClient of the session owner, but it resulted in a Time out, so I assume this isn’t possible?
If I don’t have to do this, then is this normal that the GetNumPlayers() function returns the wrong number of players? How can the other players can access the owner of the session then?

There are probably some concepts that I missed in the lobby beacon system, but since there is almsot no documentation, I’m stuck on this right now :frowning:

Could someone help me?
Thanks!

If you don’t have a dedicated server and your host is working as a listen server then you are both a client and server, since you created the session you don’t have to join, you are already in, check out the FOnlineSessionSettings->settings and read the NumPrivateConnections and NumPublicConnections, with those two you can display the amount of players connected to your session. I’m not experienced with Online Beacons but what I did to go around this was to use custom settings on my sessions, to do this I created a session with settings like settings.Set(TEXT("SETTING_CUSTOM_PARAM"), CustomSetting, EOnlineDataAdvertisementType::ViaOnlineService); and since Steam passes them every time you search for sessions then players that lookup for your sessions will have this information available without using a beacon, you only need to call FOnlineSessionSteam::UpdateSession whenever you want to update the session info.

Also I think the purpose of Online Beacons are to have them InGame so that players can lookup the match info and join once the session has already started.

Thanks for you answer!
I’m not sure to understand what you’re saying.
You’re suggesting to give up on beacons and to use the session settings instead? If I do this, my clients will have a loading time while joining the session, no? Or they don’t have to join it? Then how do they notify things like “I leave the lobby” in case of alt-f4 or connection errors?
For me the main reason I use beacons is the “clients will follow the host if he joins a game” part. Do you know if there is a way to do this without beacons?
Maybe I misunderstood you, though.

Sure! I’m suggesting you that instead of using the beacons you share the session/room info with the OnlineSessionSettings, as a host you will create and join a session so if players want they can list the session info from the main menu without having to join the host at all. They won’t have any loading time (besides waiting for Steam to retrieve the session data as you would normally would anyway).

If a player joins the session the FOnlineSessionSettings will update the NumPrivateConnections and NumPublicConnections automatically, also the PostLogin method will be called and if someone leaves the Logout/EndPlay method will be called depending on the situation.

As for “clients will follow the host if he joins a game” that’s what I meant by the beacons are mostly used for joining a player inside of a session that has already started, if that’s what you want to do then Beacons are definetely the way to go, but of course you can also use them for sharing the session info, in the end it’s all up to you.

“If a player joins the session” ← This will result in a map transition. Furthermore, I want my clients to follow the host when he’s travelling to another server, so I think your solution isn’t what I want. Thanks anyway :slight_smile:

I’m still stuck on this :frowning:

Believe it or not I’m coming back to this, you are right, what I said was wrong. I’m also using the Lobby beacons right now and you indeed need to join your Lobby with the host by creating a ALobbyBeaconClient and calling the ConnectToLobby method. My problem right now with this is that my LobbyState and LobbyPlayerState aren’t being replicated, I even made sure to setup the lobby state after I registered the ALobbyBeaconHost.

Got stuck at the same thing too. Any news on this matter OP ?

I switched to UE 4.21 recently, and I plan to use the Steam Party plugin to handle this properly.

I updated my engine to 4.21.2, and I’m now using the Steam Party plugin, so this question isn’t relevant anymore.

I released a new plugin for UE4.27, 5.0, 5.1 where I have fully implemented lobby beacons with a bunch of advanced features for party management. Check it out here: Advanced Lobby System in Code Plugins - UE Marketplace