join random room limiting 2 players

Options
Hello everyone, i have been trying to search for an answer but I believe my terms are not correct

I create a room with limit of 2 players, if 1 player leaves the room, that allows any other player to join that exact room

i need to prevent that, if a user left Not allow anyone new to join that room and possibly allow the user that left to rejoin the room. I am trying my best here to make sense , if not please let me know so i can rephrase

Comments

  • OneManArmy
    Options
    Hi, when second player joins, you can close and hide room, but in this case player will not be able to rejoin.
    You can use custom room properties to set some random key, what will allow player to rejoin and block other players.
  • nonax
    nonax
    edited December 2017
    Options
    i just figured that i can isopen = false the room, wasnt sure , thanks man,,, what i still dont know how to implement is the rejoin, was thinking on maybe saving a variable which holds if i was in a room , clear it if i exited the room freely, if i was disconnected the variable is still set then instead of joining one i would rejoin,... that makes sense ? ooh right if isopen == false i cant rejoin
  • OneManArmy
    Options
    Read in documentation about JoinRandomRoom. As i remember there was something about expected users (way to reserve slot for expected player and block other players).
  • nonax
    Options
    thank you , i am right now on that
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2017
    Options
    Hi @nonax, thank you for choosing Photon!
    Hi @OneManArmy, always good to see you active on the forum!

    you can close and hide room, but in this case player will not be able to rejoin.
    if isopen == false i cant rejoin

    These two statements are not correct.

    If you set
    PlayerTTL != 0
    when you leave room using Disconnect() or LeaveRoom(true)
    the actor is kept inside the actors list inside the room as inactive actor. This way you can rejoin the room by name with the same player using the same UserID even if the room is marked as closed (or invisible). When you rejoin you will have the same actor number.

    In any case, you can use Expected Users to allow only specific user IDs to join or rejoin.
  • nonax
    Options
    what happens if user simply rage quits, on android specifically, closing the app ? are those actions detectable ?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Yes.

    All unexpected disconnects, mainly timeout disconnect will be detectable but the callback will be triggered only after the disconnect timeout which is 10 seconds by default.

    I also forgot to mention that you should cache previously joined room names list locally or save it on server somehow. Then you can rejoin those rooms by name within PlayerTTL milliseconds of deactivation time, which is when you became inactive inside the room.