Room list returns count of 0
Hi! My goal is to get a room list with a second LoadBalancingClient while already in a room. I'm using PUN2 and latest Unity. After creating a public and with lobby-exposed-properties room like this (and giving it many seconds to exist, so no racing)...
What to do? Thanks!
Hashtable properties = new Hashtable(); properties.Add(RoomProperty.Name.ToString(), "Welcome Island X"); properties.Add(RoomProperty.Scene.ToString(), Scene.Island); string[] lobbyExposedProperties = new string[] { RoomProperty.Name.ToString(), RoomProperty.Scene.ToString(), }; RoomOptions options = new RoomOptions(); options.MaxPlayers = (byte) 8; options.IsVisible = true; options.IsOpen = true; options.CustomRoomProperties = properties; options.CustomRoomPropertiesForLobby = lobbyExposedProperties; PhotonNetwork.CreateRoom(null, options);... and then creating the secondary LoadBalancingClient like this (note I'm restricting to "us" in all region settings, also in the dashboard and PUN highlight settings) ...
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using ExitGames.Client.Photon; public class PhotonRoomPoller : MonoBehaviourPunCallbacks, ILobbyCallbacks { Action<string> callback = null; LoadBalancingClient client = null; public void GetRoomsInfo(Action<string> callback) { this.callback = callback; Debug.Log("Starting LoadBalancingClient..."); client = new LoadBalancingClient(PhotonNetwork.NetworkingClient.ExpectedProtocol); client.AddCallbackTarget(this); client.StateChanged += OnStateChanged; client.AppId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime; client.EnableLobbyStatistics = true; client.ConnectToRegionMaster("us"); // if (callback != null) { callback("Hello World"); } } void Update() { if (client != null) { client.Service(); } } void OnStateChanged(ClientState previousState, ClientState state) { switch (state) { case ClientState.ConnectedToMaster: Debug.Log("*** ConnectedToMaster"); client.OpJoinLobby(null); break; case ClientState.JoinedLobby: Debug.Log("*** JoinedLobby"); break; } } public override void OnRoomListUpdate(List<RoomInfo> infos) { Debug.Log("*** OnRoomListUpdate"); Debug.Log("Room count: " + infos.Count); // XXX foreach (RoomInfo info in infos) { Debug.Log(info); } } }... I'm getting a rooms count of 0 where it says XXX, even though the proper order of ConnectedToMaster - JoinedLobby is called before, and InLobby is true at the time of checking.
What to do? Thanks!
1
Comments
-
Hi @Philipp,
Make sure clients can see each other: connected to the same region (servers) and virtual application (AppId, AppVersion) and that you are joined to the right lobby where games are being created (LobbyId, LobbyType).
See "Matchmaking Checklist".1 -
Thank you. I'm trying to use the same region, appId, appVersion, and now also the same lobbyName and lobbyType*, as well as now also a differet playerId, all to no avail -- the room list is always of count 0.
*// Initial connect: PhotonNetwork.CreateRoom(roomName, options, new TypedLobby("Default", LobbyType.Default)); // Room poller connect: client.OpJoinLobby(new TypedLobby("Default", LobbyType.Default));
Side question: Is AppVersion the same as GameVersion? Either way, I tried all variants, and none helped so far.
Main question: How can I get the room list to show something other than a 0 count list?0 -
Hi @Philipp,Is AppVersion the same as GameVersion?AppVersion is not the same as GameVersion.
I think you did not set the AppVersion of the new LoadBalancingClient properly.
Read here.
If PUN client is connected you can set the AppVersion of the second LoadBalancingClient as follows:loadBalancingClient.AppVersion = PhotonNetwork.NetworkingClient.AppVersion;
2 -
It works now, thank you!
I had used this, note sure what that is or why it never worked:client.AppVersion = PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion;
Changing toPhotonNetwork.NetworkingClient.AppVersion
solves it.1 -
Investigating the values,
My inspector PhotonServerSettings App Version input field shows "1"
PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion shows "1"
PhotonNetwork.NetworkingClient.AppVersion shows "1_2.13"!1