Player leaving and joining room back again even after room closed

Options
Hi, I have created a random room and after 2 players joining I close the room.

What I want to do now is that when either player leaves the game and want to join back after some time they should be able to join back. Only those players should be able to join who were registered in the room before it got close.

Is there any way I can achieve this thing? Any help would be appreciated.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @roshaan,

    Thank you for choosing Photon!

    Set RoomOptions.PlayerTtl (not zero, -1 or a value high enough allowing the player to return after leaving) and use RejoinRoom or ReconnectAndRejoin. Do not use LeaveRoom(false).
  • roshaan
    Options
    Hi @JohnTube

    thank you for taking time and giving me a response back. I really appreciate this,

    So I will try using the methods you mentioned above and will update this thread accordingly.
  • roshaan
    Options
    @JohnTube Hi, I have tried using the RejoinRoom but it is not working as the player creates another room upon join failed.
    I have saved the room name in a file upon leaving and tried signed in back into that room after it was mark closed but it didn't worked.
    The player-ttl value is set to 15 minutes

    Is there any example code or demo for this?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    hi @roshaan,

    join failed.
    but it didn't worked.
    Could you show us the code you tries? What error did you get for room rejoin?
    Did you keep the same UserId when rejoining?
  • roshaan
    Options
    @JohnTube I don't get errors in the log so I don't know what it is wrong but the player creates/joins the random room as I have coded in the room failed function.
    What do you mean by userID? I don't have any userID, I just pass the room name that I want to rejoin in the PhotonNetwork.RejoinRoom(roomName)
  • roshaan
    Options
    @JohnTube
    roshaan said:

    @JohnTube I don't get errors in the log so I don't know what it is wrong but the player creates/joins the random room as I have coded in the room failed function.
    What do you mean by userID? I don't have any userID, I just pass the room name that I want to rejoin in the PhotonNetwork.RejoinRoom(roomName)

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2019
    Options
    Hi @roshaan,

    What PUN version are you using?
    You need to implement join room failure callback.
    the room failed function
    Maybe this is the one or maybe you are referring to the Join Random failure callback which is different.

    PUN1:
    - void OnPhotonRandomJoinFailed(object[] codeAndMsg)
    - void OnPhotonJoinRoomFailed(object[] codeAndMsg)

    PUN2:
    - void OnJoinRandomFailed(short returnCode, string message)
    - void OnJoinRoomFailed(short returnCode, string message)

    In order to rejoin a room, you need to keep the same UserId.
    Read about how to set UserIDs here.