Reconnecting players

Options
Hi,

we are currently developing MP game, basically it is one on one shooter for mobiles. The fact, that we have only two players in room and nobody joins additionally makes a lot of things easier. But i want solve reconnection of players. If client disconnects (it is another sad issue which is happening on our poor wifi), it is easy .. i will just join him to room again. But what if master client disconnect ? After reconnection i want him to became master client again. Is there any way to switch master client manually ? Please note, that after somebody disconnects, game will stop and wait for second player to rejoin.

Comments

  • zohaibjaved
    Options
    I think you can use PhotonNetwork.SetMasterClient function call. Pass PhotonPlayer of the client you want to make master.
  • wawro1
    Options
    Thank you! I should read documentation more carefully :)
  • Tobias
    Options
    Technically, the client that re-connects is a new player. It gets another player ID.
    The re-join works only for the master client when you use SetMasterClient, as the master also controls objects of players who are no longer online! If the 2nd player leaves and comes back, you will notice that he/she can't control objects previously created...

    Make sure to testy our solution carefully.
  • wawro1
    Options
    Thanks, yes i need to change ids of photon views, but fortunately there are only few. Only thing I am concerned about are lost RPCs. when master disconnects, second player immediately stops game, but he can send some RPCs before recognizing this fact. After reconnection master will have new ID.(I send RPCs with ID of masterClient, and not using PhotonTargets.MasterClient). So basically all RPCs sent to master will be lost.
  • Tobias
    Options
    If you'd send RPCs buffered, they are sent to the new/returning player. You can also use properties in some cases to store a "now" state.
    It's a bit tricky that messages might not reach it's destination if that client drops. But so far, I didn't have a proper solution for that. The only one would be to acknowledge each received message but that would be overkill most likely.