PhotonNetwork.GetRoomList () does not give array of rooms

Options
Hello everyone, stopped working method PhotonNetwork.GetRoomList (), but PhotonNetwork.countOfRooms shows that there is room. Please tell me what could be the reason, here's the code:
public class SearchRoom : MonoBehaviour
{
	public UMP_Manager um;
	public Text RoomListText = null;
	public Transform RoomPanel = null;
	public GameObject RoomInfoPrefab;
	private List<GameObject> CacheRoomList = new List<GameObject>();
	private float refresh = 1;

	public void UpdateRoomList()
	{
		if (!PhotonNetwork.connected)return;

		if (CacheRoomList.Count > 0)
		{
			foreach (GameObject g in CacheRoomList)
			{
				Destroy(g);
			}
			CacheRoomList.Clear();
		}

		RoomInfo[] rl = PhotonNetwork.GetRoomList();
		if(rl.Length > 0)
		{
			RoomListText.text = string.Empty;
			for (int i = 0; i < rl.Length; i++)
			{
				GameObject r = Instantiate(RoomInfoPrefab) as GameObject;
				CacheRoomList.Add(r);
				r.GetComponent<bl_RoomInfo>().GetInfo(rl[i], um);
				r.transform.SetParent(RoomPanel, false);
			}
		}
		else
		{
			RoomListText.text = "There is no room created yet, create your one.";
		}
	}

	void Update()
	{
		if(refresh > 0) refresh -= Time.deltaTime;
		else
		{
			UpdateRoomList();
			refresh = 1;
		}
	}
}

Comments

  • Tobias
    Options
    The room count is a statistic value, which is sent by the Master Server automatically. It gives the clients an overview of how active the game is currently.
    To get a room list, you need to join a lobby. That makes sure you get the list only when you really need it (and show it). Also, lobbies can be used to separate rooms by mode, skill or whatever else you can come up with.
    PUN has a feature to automatically join the default lobby. This is off by default.
    Here is a description how to turn it on: http://forum.photonengine.com/discussion/6426/autojoinlobby-disabled-in-pun-v1-60#latest
  • Xytabich
    Options
    Auto-join is turned on, and i'm connected to the lobby, but rooms list not give.
  • Tobias
    Options
    The next check would be if you create rooms in that lobby? Do you use CreateRoom's TypedLobby parameter? Is the room maybe invisible?

    The Worker Demo from the PUN package lists rooms as well. That works for me, so in general, this should do.
  • Xytabich
    Options
    In the Demo Worker also not work a list of rooms. A few days ago everything worked, but I have not changed scripts.
  • OneManArmy
    Options
    Yesterday i downloaded latest version of PUN 1.62 (Oct 13, 2015), from asset store and i also noticed the same problem.
    I can confirm - in Demo Worker you also don't get list of rooms.
  • Tobias
    Options
    Please double-check you enabled Auto-Join Lobby in the PhotonServerSettings file.
    This is a per-project setting.

    I just ran the demo with that setting and it showed my room just fine. Make sure to not use a new GameVersion and PUN version in all builds (those separate players) and make sure you use the same region in all builds (regions are fully separated).
  • OneManArmy
    Options
    Thanks.
  • Tobias
    Options
    @OneManArmy: Let me know if it helped. If not, I will want to check if anything is odd in PUN!
  • OneManArmy
    Options
    Yes, everything works fine now ( AutoJoinLobby was disabled).
  • cityhost
    Options
    thanks, Tobias it helps me too

  • pjenness
    pjenness
    edited December 2016
    Options
    Hiya

    Im watching this thread as I have similar situation

    My App has x levels. Its not a game per see where you match players and start. Its a social inaction with x fixed number of maps (at the moment 4..but grows as I make content)

    I have set auto log into lobby true.

    I am making a room whilst in a lobby:
    PhotonNetwork.JoinOrCreateRoom (m_roomName, new RoomOptions () { IsVisible = true, MaxPlayers = m_maxMembers }, TypedLobby.Default);
    It looks like when I create the room and join, I exit the lobby.

    I want to know how I can check from one room, the names and members of other rooms. I current expect 1 room per map (that has an active player in) to be available. They should be queriable from each other room so I can find a friend who maybe in a differnt map to me)

    Does that make sense?

    At the moment when I do:
    RoomInfo[] roomlist = PhotonNetwork.GetRoomList ();
    		if (roomlist.Length > 0) {
    			
    			foreach (RoomInfo ri in roomlist) {
    				
    				m_allRooms.Add (ri.name);
    			}
    		} else {
    			Debug.Log ("No Rooms Available Yet");
    		}
    
    I get no return values for my list of rooms, and also I am no longer in any lobby.

    DO I need a lobby to remain active to store info about the used rooms to be queried?

    Cheers

    -P




  • pjenness
    Options
    Any ideas why I cant see the user list of a different room on same game?

    Im guessing I need a persistant active Lobby which both rooms belong to...but for some reason I leavehe lobby and cat see any other room info.

    -P
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @pjenness,

    By design, Photon does not allow you to be inside a room and inside a lobby at the same time.

    If your goal is to find out if a friend is in another room then you can make use of FindFriends.

    If you want to know more information about that room then you have different options:
    - not recommended: the app should contain 2 clients, one that joins rooms and one that stays on the lobby forever just to query list of rooms.
    - use another way of exchanging information about room lists: Photon chat for instance.
    - if there won't be too many users, you can group them per room and have different maps per room.
  • pjenness
    pjenness
    edited December 2016
    Options
    Hiya

    Thanks JohnTube.

    Does photon not have a concept of what rooms are created inside an AppId?
    (eg AppID/RoomA AppID/RoomB)

    As my rooms are based on the map level itself, and limited in users I think that would be the best way. The Room name is always known. Perhaps that is the best way?
    Polling to see if a room exists (ie someone has entered that map so it has created the room) and then listing users in that map.
    Does that functionality exist:

    If appID>/roomName exists, list room info (users)

    From reading the docs it looks like I can only do that from a Lobby. Which is not really what I want (unless its some how easy to spawn a photon instance that goes back to the lobby and checks the rooms, but like you say "Not Recommended"

    At the moment Im looking at about 5-6 rooms ,a and 20 people max in a room. Its not a big app so I know the rooms Im looking for.

    Cheers and Happy Holidays.

    -P

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2016
    Options
    If you want to know who is joined to a room you need to join it.
    If you want to know if someone is joined to a room and the room name then use FindFriends.
    Otherwise, when you are not joined to a room and joined to a lobby, you can make use of "Lobby Stats" to know how many users are joined per room.

    If room names are known and you can tolerate some kind of "spectator mode" then you can make use of JoinOrCreate feature to enter rooms just to know who is joined and then choose to stay or leave.

    If you need more, you can have a web service that keeps track of users and rooms. So you can implement this outside of Photon.
  • pjenness
    Options
    ok, makes sense

    What I want to try is

    I am playing in my room/map as local client.

    I bring up a menu and poll other rooms to see who is online.
    I want to spawn a second Photon Client, that goes to the Lobby, does a room search. Reports the info back and then destroys itself. This way it at least wont continually take 2x CCU instances.

    Im looking at the create new client part. PhotonNetwork is static so I can instance that, so how would I instance a new client, that doesnt interfere with the current game, but can do the stuff I need it to do?

    ie What class am I creating?

    Cheers and happy new year!

    -P




  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    @pjenness

    I still do not recommend this approach of having two Photon Clients per device.
    If you must do it then I think you need a new instance of a NetworkingPeer.
  • pjenness
    Options
    JohnTube said:

    @pjenness

    I still do not recommend this approach of having two Photon Clients per device.

    I agree.. so is it possible to expose this as a default feature. If you know the room names to be able to check them from any where.

    You are sort of doing it with find friends right..you know the friend ID and using it to get extra information.
    In this case you know the appID and the room names and use it to get extra information (if it exists).


    Cheers

    -P