Do I need to update the room's expected player list if a single player drops out before joining?
Options
If I join a room and set the expected player id's, the room will set aside a slot for each user. If for some reason one of those users will not join how can I update the expected users property so that there isn't a single unused spot in the room?
I see there is an option to clear all expected players, but that seems like a hassle to manage given the very clear warning that this could have a race condition with joining players.
I've read this forum post and don't think it covers the full subject: https://forum.photonengine.com/discussion/8259/callback-for-updates-to-rooms-expectedusers
I'm thinking the solution right now is to:
1) Close the room.
2) Wait X seconds.
3) Clear the expected users list.
4) Set the expected users list with all the old values minus the one we know isn't there.
5) Reopen the room.
I'm stuck at step 4 right now.
I see there is an option to clear all expected players, but that seems like a hassle to manage given the very clear warning that this could have a race condition with joining players.
I've read this forum post and don't think it covers the full subject: https://forum.photonengine.com/discussion/8259/callback-for-updates-to-rooms-expectedusers
I'm thinking the solution right now is to:
1) Close the room.
2) Wait X seconds.
3) Clear the expected users list.
4) Set the expected users list with all the old values minus the one we know isn't there.
5) Reopen the room.
I'm stuck at step 4 right now.
0
Best Answer
-
Hi @RustyPencil,
Thank you for choosing Photon!
No need to do all of this.
All you need to do is to update the expected users' string array.
Even with closing the room and reopening there is always room for "race conditions".
The thing is that if there is a spot in the room a player could join and claim it before someone else OR before another client tries to close the room or change its expected users.
Or a player could try to join a room as it had a free spot and during the join process the room becomes full or closed or that spot is no longer available, in this case the player will not be able to join.
In your case changing expected users string array directly is enough.
you could also use the exact code provided by Jean or try these extension methods.5
Answers
-
Hi @RustyPencil,
Thank you for choosing Photon!
No need to do all of this.
All you need to do is to update the expected users' string array.
Even with closing the room and reopening there is always room for "race conditions".
The thing is that if there is a spot in the room a player could join and claim it before someone else OR before another client tries to close the room or change its expected users.
Or a player could try to join a room as it had a free spot and during the join process the room becomes full or closed or that spot is no longer available, in this case the player will not be able to join.
In your case changing expected users string array directly is enough.
you could also use the exact code provided by Jean or try these extension methods.5