ConnectToRegion() problem after latest update

Options
chaozz
chaozz
Since I updated PUN+, OnReceivedRoomListUpdate() is no longer triggered after connecting with a second region. Here is the code I have been using for the last year in my game:
	void LoadServerList() {
		if (ConnectionStage == 0)	
		{
			// clear the current server list (if any)
			ServerList_full = new List<string>();
			ServerList_name = new List<string>();
			
			// connect to read EU rooms
			PhotonNetwork.ConnectToRegion (CloudRegionCode.eu, Version);
		}
		
		if (ConnectionStage == 1)	PhotonNetwork.ConnectToRegion (CloudRegionCode.us, Version); // read US rooms
		
		if (ConnectionStage == 2)	
		{
			// add the missing servers
			for (int i = 0; i < ServerList_all.Length; i++) 
			{
				if (!ServerList_name.Contains(ServerList_all[i])) 
				{
					ServerList_name.Add (ServerList_all[i]);
					ServerList_full.Add (GetFullServerName (ServerList_all[i], 0, maxPlayers));
				}
			}
			ConnectionStage++;
		}
	}
	
	void OnReceivedRoomListUpdate() 
	{
		if (Joining) return;

		foreach (RoomInfo game in PhotonNetwork.GetRoomList()) 
		{
			ServerList_name.Add (game.name);
			ServerList_full.Add (GetFullServerName (game.name, game.playerCount, game.maxPlayers));
		}
		PhotonNetwork.Disconnect();
		ConnectionStage ++;
		LoadServerList();
	}
So OnReceivedRoomListUpdate() is called after I connect first to the EU regon. Then when PhotonNetwork.ConnectToRegion (CloudRegionCode.us, Version) is executed, OnReveivedRoomListUpdate() is never fired.

PS: It does connect to the US region, because I can bypass the room list update and join a US based server. But again OnReceivedRoomListUpdate() is only triggered the first time now.

What is going wrong?

Comments

  • chaozz
    Options
    I've been banging my head against the wall because it really frustrates me.

    In short:
    I connect to the EU region with PhotonNetwork.ConnectToRegion (CloudRegionCode.eu, Version);
    Both OnJoinedLobby() and OnReceivedRoomListUpdate() are called.

    I read the rooms, then I
    PhotonNetwork.Disconnect();
    and connect to the US region with PhotonNetwork.ConnectToRegion (CloudRegionCode.us, Version);

    Now however Both OnJoinedLobby() and OnReceivedRoomListUpdate() are not called.

    AutoJoinLobby is enabled in my PUN settings.

    Is there a different way to query lobbies across different regions? Or is this a bug?

    NOTE: The method described above worked fine until I updated to 1.80 yesterday.
    NOTE2: I already renamed game.name to game.Name reflecting the new changes in names.
  • chaozz
    Options
    **BUMP**

    Anyone?
  • chaozz
    Options
    up.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2016
    Options
    Hi @chaozz,

    Please try doing the subsequent LoadServerList() calls only when client is completely disconnected. So either make a coroutine that waits for the client state to be disconnected or move the call to the disconnection callback as follows:
    void OnReceivedRoomListUpdate() 
    	{
    		if (Joining) return;
    
    		foreach (RoomInfo game in PhotonNetwork.GetRoomList()) 
    		{
    			ServerList_name.Add (game.name);
    			ServerList_full.Add (GetFullServerName (game.name, game.playerCount, game.maxPlayers));
    		}
    		PhotonNetwork.Disconnect();
    		ConnectionStage++;
    	}
    
    void OnDisconnectedFromPhoton() {
        LoadServerList();
    }
  • chaozz
    Options
    Thank you, I'll try this and report back here. Again, thank you so much for taking the time to respond.
  • chaozz
    Options
    @JohnTube I just wanted to confirm your fix works. Thank you so much! I can finally release a new build of Survius!