Leave room ignoring TTL
Options
I am using a photon room with a PlayerTtl set to several minutes to support rejoining games. There are some situations, however where the player chooses to leave (for example before the game starts) where I want to be able to actually have them leave the room and be removed from the player list.
Currently the player calls PhotonNetwork.LeaveRoom() but they appear to remain in the player list and if they happen to try to join that same game again they get an error saying their ID is already in the room. (and that they should be Rejoining instead of Joining)
Is it possible to totally leave a room?
side question: How can you tell if a room can be Rejoined by a player? The player list is not available outside the room so I can't tell if it's rejoinable until I try and get an error.
Thank you for your time.
Currently the player calls PhotonNetwork.LeaveRoom() but they appear to remain in the player list and if they happen to try to join that same game again they get an error saying their ID is already in the room. (and that they should be Rejoining instead of Joining)
Is it possible to totally leave a room?
side question: How can you tell if a room can be Rejoined by a player? The player list is not available outside the room so I can't tell if it's rejoinable until I try and get an error.
Thank you for your time.
0
Best Answer
-
Hi @ScottS,
Thank you for choosing Photon!Is it possible to totally leave a room?Yes, it may not be implemented in PUN...yet. I'm more familiar with the Unity Realtime SDK which is a bit different from PUN.
If PUN does not offer an overload method forLeaveRoom()
that takes a boolean parameter I can give you the code for this.
In Unity Realtime SDK, we useloadBalancingClient.OpLeaveRoom(false)
.This is not possible. You need to keep track of rooms and players yourself, either by caching info locally or using webhooks/webRPCs.
How can you tell if a room can be Rejoined by a player?
Another customer requested the option to change the PlayerTTL or EmptyRoomTTL post room creation.
IDK when this could be available but it could be an option for you as well.5
Answers
-
Hi @ScottS,
Thank you for choosing Photon!Is it possible to totally leave a room?Yes, it may not be implemented in PUN...yet. I'm more familiar with the Unity Realtime SDK which is a bit different from PUN.
If PUN does not offer an overload method forLeaveRoom()
that takes a boolean parameter I can give you the code for this.
In Unity Realtime SDK, we useloadBalancingClient.OpLeaveRoom(false)
.This is not possible. You need to keep track of rooms and players yourself, either by caching info locally or using webhooks/webRPCs.
How can you tell if a room can be Rejoined by a player?
Another customer requested the option to change the PlayerTTL or EmptyRoomTTL post room creation.
IDK when this could be available but it could be an option for you as well.5 -
When I posted the question, upon exiting the room I was disconnecting and reconnecting to photon because I though I had to. I'm noticing that if I only leave the room and return to the lobby and do NOT disconnect from photon, I can simply JoinRoom and it works. Does the "TTL inactive ID" stuff only happen when you disconnect?
When you said "I can give you the code for this." is the code you're referring to: "loadBalancingClient.OpLeaveRoom(false)" Or is there something else?0 -
Does the "TTL inactive ID" stuff only happen when you disconnect?I don't understand.When you said "I can give you the code for this." is the code you're referring to: "loadBalancingClient.OpLeaveRoom(false)" Or is there something else?If you need to leave the room for good (actor will be removed from actors list no matter what the PlayerTTL value is and you will not be able to rejoin but you can still try to join with a new actor number) I can give you the code to add to PUN which is the same as what is available in Unity Realtime SDK and can be called using it with
loadBalancingClient.OpLeaveRoom(false)
.0 -
By "TTL inactive ID" I mean, if I properly call
LeaveRoom
then the player seems to get removed from the player list and they don't linger as an inactive player.
But if I instead callDisconnect
They become an inactive player that remains in the roomlist. Is this correct?0 -
Yes that should be correct.0