Unable to create new room with master on leaving the room

Options
JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.
UnityEngine.Debug:LogError(Object)
PhotonNetwork:JoinRandomRoom(Hashtable, Byte, MatchmakingMode, TypedLobby, String, String[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1960)
CompeteController:Start() (at Assets/Script/CompeteController.cs:131)


i have this on 131 line
TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);    // same as above
string sqlLobbyFilter = "C0 = \""+ UiManager.lobbyName + GameManager.instance.CharacterId+ "\"";   // find a game with mode 0
PhotonNetwork.JoinRandomRoom (null,10,MatchmakingMode.FillRoom,sqlLobby, sqlLobbyFilter);
Hi,

I have created a room and other players join the room as a client. SO when the master leave the room and that master again create some another room , i am getting the above error.

but when the client disconnect and it creates a room , the room gets created.


here is my code
void Start ()
	{
		Debug.Log ("System.DateTime.Now" + System.DateTime.Now ) ;
		transform.Find ("loadingBar").gameObject.SetActive (true);
		Debug.Log ("lobbyName" + UiManager.lobbyName);

		competePlayeScale = true;

		TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);    // same as above
		string sqlLobbyFilter = "C0 = \""+ UiManager.lobbyName + GameManager.instance.CharacterId+ "\"";   // find a game with mode 0
		Debug.Log("sqlLobbyFilter"+sqlLobbyFilter);
		PhotonNetwork.JoinRandomRoom (null,10,MatchmakingMode.FillRoom,sqlLobby, sqlLobbyFilter);
		Debug.Log ("JoinRandomRoom Start()");

	}

void OnPhotonRandomJoinFailed()
	{
		roomName = GameManager.instance.userId;
		Debug.Log ("OnPhotonRandomJoinFailed");
		RoomOptions roomOptions = new RoomOptions();
		roomOptions.MaxPlayers = 10;
		roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable (){ {   "C0",UiManager.lobbyName + GameManager.instance.CharacterId } };
		roomOptions.CustomRoomPropertiesForLobby = new string[] { "C0" };
		TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);
		PhotonNetwork.CreateRoom (roomName, roomOptions ,sqlLobby);
		Debug.Log ("CreateRoom");
		Invoke ("CheckOtherPlayerInRoom", 30);
	}

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @wasifk308,

    You can call CreateRoom only when connected to Master Server.
    You need to wait for OnConnectedToMaster or OnJoinedLobby callbacks to be called to make sure you can call CreateRoom.
    You should move CreateRoom call from Start method and put it somewhere else where you are certain it will be called after OnConnectedToMaster or OnJoinedLobby. You can also use a coroutine inside Start to wait for client to be connected to Master Server or even make Start a coroutine itself but I do not recommend that.
  • wasifk308
    Options
    @JohnTube Thanks