OnConnectedToMaster() doesnt trigger

hey I am really new to Photon and i have following issue:

When I start my game and create a room everything works fine but as soon as i go back to the menu and try to create a new Room i get this Error:

"JoinOrCreateRoom failed. Client is on GameServer (must be Master Server for matchmaking)but not ready for operations (State: Leaving). Wait for callback: OnJoinedLobby or OnConnectedToMaster. "

I make sure that I leave the room before Menu gets Loaded. Can Anyone help me?

Comments

  • Hi @Clyon,

    Thank you for choosing Photon!

    Call LeaveRoom() to leave the room and wait for OnConnectedToMaster() to go back to the menu.
  • ClyonClyon
    edited February 10
    i tried but it ended up never going to the menu.
    Thats my code for going back:
    public void clickHomeButton()
        {
            StartCoroutine("disconnectRoom");
        }
    
        IEnumerator disconnectRoom()
        {
            PhotonNetwork.LeaveRoom();     
            while (PhotonNetwork.InRoom)
               yield  return null;
            PhotonNetwork.LoadLevel(2);
        }
    
  • JohnTubeJohnTube mod
    edited February 10
    assuming you extend MonoBehaviourPunCallbacks:
    public void clickHomeButton()
        {
                 if (!PhotonNetwork.LeaveRoom())
                 {
                      Debug.LogError("Leaving room failed");
                  }    
        }
    
       public void override OnLeftRoom()
       {
             PhotonNetwork.LoadLevel(2);
       }
    
       public void override OnConnectedToMaster()
      {
      }
    
  • thank you for your reply!!!
    I tried your code and got this error :

    "Operation LeaveRoom (254) not called because client is not connected or not ready yet, client state: Leaving"

    really dont understand why ;/
  • i just tried to see if i am connected when i click button with debug.log(PhotonNetwork.IsConnected) and it returns true
  • also just found out that it works with only one person in the room but not if 2 person are in the room
  • okay finally figured it out!!! thanks !!!
Sign In or Register to comment.