How to rejoin the room after a player disconnect from Photon

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to rejoin the room after a player disconnect from Photon

charlesso
2016-04-07 09:08:43

Hi guys,

I am now using realtime for Photon-iOS-Sdk_v4-1-0-4 now.
I've got difficulties in rejoining room for a player who has been disconnected from Photon because of timeout.

When I was using
--- LoadBalancingClient.opJoinRoom(getLastRoomName(),-1);
to rejoin the room which I have saved the room name and is able to get back by getLastRoomName(). I have an error 32748 which prevent me from rejoining the game.

line: 668 - OperationResponse - operationCode: 226, returnCode: 32748 (User does not exist in this game) ( debugReturn L:79)
[ServerDebug general 07-04-2016 16:40:33:04] Photon: 2016-04-07 16:40:33,058134 ERROR Client.cpp onOperationResponse()
line: 773 - opJoinRoom failed with errorcode 32748: User does not exist in this game. Client is therefore returning to masterserver! ( debugReturn L:79)
[ServerErr 07-04-2016 16:40:33:04] opJoinRoom() failed: User does not exist in this game [RoomName] ( joinRoomReturn L:515)

I have set the room option as follow as well:

ExitGames::LoadBalancing::RoomOptions option =
ExitGames::LoadBalancing::RoomOptions(
true,
true,
(nByte)2,
customRoomProperties,
roomFilterlist,
"",
ExitGames::LoadBalancing::LobbyType::DEFAULT,
300000, //PlayerTTL
0); //EmptyRoomTTL

Please help and suggest me ways to get it through. Thanks

Comments

Kaiserludi
2016-04-07 16:40:25

Hi @charlesso.

1 .
Please use

  
LoadBalancingClient::opJoinRoom(lastJoinedRoom, lastPlayerNr);  

with the second parameter being the player nr that was assigned to the local player before he left the room.

2.
Also please assure that you explicitly pass 'true' for the 'willComeBack' flag to LoadBalancingClient::opLeaveRoom(). The default value for that parameter is false.

3.
You need to pass suitable values for the ttls. Your current values of 30000 for the player ttl and 0 for the empty room ttl mean that a player has 30 seconds (30,000 ms) to rejoin, after he left, until he is considered to have left for ever and gets completely removed from that room, but if all players leave the room, then the room will get closed entirely immediately (after 0ms), so that no one can rejoin it anymore, even if their player ttl hasn't run up yet. If that is not your intention, then please adjust your values accordingly.

PS:
RoomOptions have chain-able setters, so that you do not have to pass all those default parameter values and so that it's immediately obvious which value sets which option:

  
mLoadBalancingClient.opCreateRoom(name, ExitGames::LoadBalancing::RoomOptions().setMaxPlayers(2).setCustomRoomProperties(customRoomProperties).setPropsListedInLobby(roomFilterList).setPlayerTtl(30000).setEmptyRoomTtl(0));  

charlesso
2016-04-08 00:41:33

Thanks for your prompt relpy.
Let me try your suggestions.

For 2,
Do you mean that I needa call
mLoadBalancingClient.opLeaveRoom(true);
when the client was disconnected by photon?

In my case, I have put my game in background and wait for 10 sec to let it disconnect from photon. and try to rejoin the same room with the same player again to resume the game.

thanks

charlesso
2016-04-08 04:34:17

I have got successfully rejoin now.

Before getting timeout from photon,
I have called opLeaveRoom(true) right before the game go to background.

Thanks for help.

charlesso
2016-04-08 10:06:09

Hi Kaiserludi,

For further test on my rejoining flow.
I found that the rejoin is only work when the client who put the game in background and come back within 10 sec.
After 10 secs, I still got error 32748, User does not exit in this game.

[ServerDebug general 08-04-2016 17:59:08:04] Photon: 2016-04-08 17:59:08,375686 ERROR Client.cpp onOperationResponse() line: 668 - OperationResponse - operationCode: 226, returnCode: 32748 (User does not exist in this game) ( debugReturn L:78)
[ServerDebug general 08-04-2016 17:59:08:04] Photon: 2016-04-08 17:59:08,376106 ERROR Client.cpp onOperationResponse() line: 773 - opJoinRoom failed with errorcode 32748: User does not exist in this game. Client is therefore returning to masterserver! ( debugReturn L:78)
[ServerErr 08-04-2016 17:59:08:04] error Code : 32748 ( joinRoomReturn L:537)
[ServerErr 08-04-2016 17:59:08:04] opJoinRoom() failed: User does not exist in this game [Charles] ( joinRoomReturn L:538)

Please help again , thanks

Kaiserludi
2016-04-08 10:55:28

Hi @charlesso.

Do you mean that I needa call mLoadBalancingClient.opLeaveRoom(true); when the client was disconnected by photon?
No. I just meant that when you want to regularly leave a room and then want to rejoin it later on, then you need to leave it with opLeaveRoom(true) and not with opLeaveRoom(false) or opLeaveRoom(). When your client gets disconnected, then you do not need to leave the room at all, as your disconnect will implicitly be triggering an opLeaveRoom() call on the server side, after the disconnect timeout kicks in and when you honored the other points from my list above, then this call will be an opLEaveRoom(true) call.

Is your leaving client the only one inside that room? In that case that you can't rejoin anymore after 10sec is probably due to not setting the emptyRoomTtl to a suitable value like I have described under 3. in my previous post. At the moment the server detects that the client disconnected and therefor lets it leave the room, there is no active client inside the room anymore. So the server starts counting down the emptyRoomTtl and when it reaches 0, then the room gets closed and no one can rejoin anymore. As you set that value to 0, the room gets closed immediately when there is no active client inside anymore.

unitylearner
2016-05-24 13:06:07

I want to disconnect user when he goes in background , and its in android phone . Any suggestions ?

Kaiserludi
2016-05-24 13:33:03

Hi @unitylearner.

From your other posts I assume that your question is about PUN. If that is correct then please ask it in the PUn specific subforum, as this thread is a) about a completely different topic and b) not about PUN, but about the C++ client API.

unitylearner
2016-05-24 13:48:48

Its says Photon . Thats why i asked here. Ok Let me ask some where else

Back to top