How to rejoin the room after a player disconnect from Photon

Options
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

Best Answers

  • Kaiserludi
    Kaiserludi admin
    Answer ✓
    Options
    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));
    

Answers

  • Kaiserludi
    Kaiserludi admin
    Answer ✓
    Options
    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
    Options
    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
    Options
    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
    Options
    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
  • unitylearner
    edited May 2016
    Options
    I want to disconnect user when he goes in background , and its in android phone . Any suggestions ?
  • Kaiserludi
    Options
    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
    Options
    Its says Photon . Thats why i asked here. Ok Let me ask some where else