Lobby players list doesn't update!

Why “Players” list doesn’t update when a new player join the lobby that I created?

Should I use LocalLobby as in “com.unity.services.samples.game-lobby” project?

I used Photon and SmartFoxServer network solutions but I haven’t seen such a use.

Do you have a plan to change this use?

Have a good day.
Thanks.

I work on “Lobby” and “Lobby Data”
Current lobby object’s data changes when run “LobbyService.Instance.UpdateLobbyAsync” method.

But as I said in my first post.: Players list doesn’t change.
Is there any road map to change this behavior?

Edit:
Folks, This Lobby behavior is very strange.
When Host player change the “Public Lobby Data”; host’s current lobby instance’s “lobby data” is changing.
But other player’s current lobby instance’s “lobby data” doesn’t change!
Note: I don’t use “LocalLobby” structure and just want to understand Lobby behaviour.

Hi Mj-Kkaya,

The current expectation is that all of the players in your lobby will periodically poll the Lobby server to get the newest version of the lobby. If you call “UpdateLobbyAsync”, the player calling that will see the updated lobby, and likewise if you join a lobby as a player, the player will see themselves in the lobby. However, all other players will not know about any changes unless they are periodically calling “GetLobbyAsync” to refresh their local state. Unless you manually update your local copy of a lobby, it will not reflect the changes made by other players.

It is worth mentioning that real-time Lobby events are coming soon, meaning players will be able to get notified about other players’ changes without having to call “GetLobbyAsync”.

Thanks for reply bartj-unity.
Will we not need to use the “LocalLobby” object instance after this update?

Hi bartj-unity.
I’m working on Lobby 1.1.0-pre.4 version.
So, I’m using “LobbyChanged” event for change local lobby instance like this.
Is this usage correct?

m_LobbyEventCallbacks.LobbyChanged += OnLobbyChanged;

private void OnLobbyChanged(ILobbyChanges lobbyChanges)
{
if(!lobbyChanges.LobbyDeleted)
lobbyChanges.ApplyToLobby(m_CurrentLobby);
}```

Yup, that looks correct. Our Lobby events documentation may be useful for you.

1 Like

Hi alexpro23,

Which version of the Lobby package are you using? And could you elaborate on who’s making the changes to the lobby in this scenario?

Hi bartj, thanks for replying. I fixed my issue by updating to the newest (pre-5) version of lobby after I found this other post: https://discussions.unity.com/t/915521

Apparently it was an issue on lobby’s side with something cache-related.

@bartj-unity If a lobby player kills the app or disconnects the internet other players do not get the OnPlayerLeftLobby event even after a timeout period. Please fix this. issue. Tested on android.
Using Lobby SDK version 1.1.0 Pre-5

Hi @sathya ,
Do you have multiple “Environment”?
And could you check “Disconnect Removal Time” at Lobby Config page?

I have two Environments “Dev” and “Production”, I have kept 30secs in both environments.

I have the same problem, if player disconnects without leaving the lobby properly, lobby thinks the player never leaves. Disconnect removal time does not seem to work as I expect it to… surely the solution cant be to manually remove or kick a client that disconnects? Then finding the correct player to remove from the lobby would require to add clientID in the lobby options.

3 Likes

Hey I have the same problem did you find a solution?

i think you need to make the host and any player who joines the lobby to subscribe to the lobby
, and attach a callback event to the player,

string lobbyName = "new lobby";
int maxPlayers = 8;
CreateLobbyOptions createLobbyOptions = new CreateLobbyOptions
{
    IsPrivate = true,
    Player = GetPlayer(),
    Data = new Dictionary<string, DataObject>
    {
        {"GameMode", new DataObject(DataObject.VisibilityOptions.Public,"CaptureTheFlag") },
        {"Map",new DataObject(DataObject.VisibilityOptions.Public,"de_dust2") }
    }
};
Lobby lobby = await Lobbies.Instance.CreateLobbyAsync(lobbyName, maxPlayers, createLobbyOptions);
string lobbyId = lobby.Id;
var callbacks = new LobbyEventCallbacks();
callbacks.LobbyChanged += OnLobbyChanged;
try
{
    var m_LobbyEvents = await Lobbies.Instance.SubscribeToLobbyEventsAsync(lobbyId,callbacks);
}catch (LobbyServiceException ex)
{
    switch (ex.Reason)
    {
        case LobbyExceptionReason.AlreadySubscribedToLobby: Debug.LogWarning($"Already subscribed to lobby[{lobby.Id}]. We did not need to try and subscribe again. Exception Message: {ex.Message}"); break;
        case LobbyExceptionReason.SubscriptionToLobbyLostWhileBusy: Debug.LogError($"Subscription to lobby events was lost while it was busy trying to subscribe. Exception Message: {ex.Message}"); throw;
        case LobbyExceptionReason.LobbyEventServiceConnectionError: Debug.LogError($"Failed to connect to lobby events. Exception Message: {ex.Message}"); throw;
        default: throw;
    }
}

and then you call the callback event anywhere in the code

void OnLobbyChanged(ILobbyChanges changes)
{
    changes.ApplyToLobby(joinedLobby);
}

Hi,

Lobby does not currently have the ability to detect a player sudden disconnection on his own yet. The host has to kick the disconnected player indeed.
That being said, if Lobby is paired with Relay, it can detect such disconnection.

If you are using Unity6, I encourage you to have a look at our new Multiplayer SDK which bundles (Lobby, Relay, Matchmaker, Multiplay, Distributed Authority) in one package and streamlines their usage including setting up Netcode for GameObject.
For example, creating a Lobby paired with Relay is as easy as creating a Session with Relay:

var options = new SessionOptions() { MaxPlayers = 2 }.WithRelayNetwork();
var session = await MultiplayerService.Instance.CreateSessionAsync(options);

(provided the services have been initialized)