Matchmaking on Random Rooms

Options
Hey there,

I'm trying to match players with a single rating parameter. I'm faced with an issue, when I call
PhotonNetwork.JoinRandomRoom(null, 6, MatchmakingMode.FillRoom, sqlLobby, sqlFilter);
i'm not able to decide if it fails or not ? If I give to enough time for next try OnJoinedRoom events will be called then everything works correctly but if i try to connect quickly to next room there is chance i'm getting an error. Full matchmaking code is here ;
		void OnJoinedRoom() {
			StopCoroutine("JoinRoom");
			networkStatus.text = PhotonNetwork.connectionStateDetailed.ToString();
		}

		// Class Member Methods

		void CreateRoom(int mmr) {
			RoomOptions options = new RoomOptions() { isOpen = true, isVisible = true, maxPlayers = 6 };
			options.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", mmr } };
			options.customRoomPropertiesForLobby = new string[] { "C0" };
			PhotonNetwork.CreateRoom(null, options, sqlLobby);
			networkStatus.text = "Created room with " + mmr;
		}

		IEnumerator JoinRoom(int mmr) {
			int tryCount = 0;
			while (tryCount++ < 3) {
				string sqlFilter = "C0 > " + (mmr - 50 * tryCount) + " AND " + "C0 < " + (mmr + 50 * tryCount);
				networkStatus.text = "Trying to connect MMR : " + sqlFilter;
				PhotonNetwork.JoinRandomRoom(null, 6, MatchmakingMode.FillRoom, sqlLobby, sqlFilter);
				yield return new WaitForSeconds(0.5f);
			}
			CreateRoom(mmr);
		}

		// Game Event Handlers;

		public void OnJoinClicked() {
			string name = playerName.text;
			int mmr = int.Parse(rating.text);
			PhotonNetwork.player.name = string.IsNullOrEmpty(name) ? "GUEST " + Random.Range(1, 1000) : name;
			StartCoroutine("JoinRoom", mmr);
		}

When I click Join button, starting a coroutine "IEnumerator JoinRoom(int mmr)" it tries 3 times while relaxing mmr(Matchmaking rating) here is the problem if i wait like 3 seconds at "yield return new WaitForSeconds(3f);" there is no problem (But still can't guarantee maybe player found an existing room but still didn't join room) but if i keep it like WaitForSeconds(1f) everytime it tries 2nd time to join a new room actually while joining first room.

I also tried bool result = PhotonNetwork.JoinRandomRoom(...) , but result returns true everytime in that case (huh why ?) Can someone point me how can I decide before looking a next room if client will be connected or not ?

Comments

  • vadim
    Options
    Handle results of current JoinRandomRoom before calling next one (do next call in OnPhotonJoinRoomFailed)
    Do you really need several successive JoinRandomRoom calls? May be it's possible merge everything in single sql query call?

    PhotonNetwork.JoinRandomRoom always returns true while you are connected to lobby. It just says that operation started normally.