PUN2 - PhotonNetwork.JoinRandomRoom Timeout

Options
Hi,

Is there any timeout for PhotonNetwork.JoinRandomRoom in the callbacks for PUN2? I am just checking before I implement my own. It seems that there is none (after several tests). Otherwise, that might be a good addition to the codebase in a future update.

Thank you.

Comments

  • tcmeric
    Options
    Sometimes this will just hang and never return any callback. I am thinking I better add a coroutine to eventually fail and instead create a new room.
            var tryingToJoinRandomRoom = PhotonNetwork.JoinRandomRoom();
            Debug.Log("Trying to join random room is : " + tryingToJoinRandomRoom);
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2019
    Options
    Hi @tcmeric,

    There is no timeout.
    But if the server does not find a match it will return an error response.
    Usually, in the error response callback, you create a new room.

    Implement IMatchmakingCallbacks.OnJoinRandomFailed(short returnCode, string message) (if you do, do not forget to register and deregister class) or extend MonoBehaviourPunCallbacks and override OnJoinRandomFailed.

    Read more about callbacks.
  • tcmeric
    Options
    Hi, thanks John. Thank you for posting. I figured out the issue. I had a called back method implemented for
    public override void OnJoinRoomFailed(short returnCode, string message)
    
    In offline mode, a room can be successfully joined, called "Offline Room". So I didnt figure out I was using the incorrect callback. When online, no room is automatically created.

    Interesting that offline mode automatically has a room created, but that for online mode this is different. A little quirk :)

    I have now used the correct call back method.