Changes in PUN2 ReconnectAndRejoin()

Options
I am trying to migrate a small project built with PUN Classic onto PUN2 and having some trouble figuring out if there are changes in ReconnectAndRejoin(), and if so, how to work with the new version.

Context of code: I simulate a loss of internet connectivity by switching off WiFi on the computer and test re-connection by switching it on again after a few seconds.

In the older PUN classic, I repeatedly called ReconnectAndRejoin() in the OnDisconnectedFromPhoton() callback till the internet connection is restored. Once connectivity is restored, the last ReconnectAndRejoin() would put the user back into the original room.

However, a similar approach seems to fail with PUN2. I try to repeatedly call ReconnectAndRejoin() in the OnDisconnected(Disconnect cause) callback but see that ReconnectAndRejoin() fails on the second/third iteration as the state of NetworkingClient.LoadBalancingPeer.PeerState has changed from 'Disconnected' to 'Connecting'. After 2 attempts to ReconnectAndRejoin(), we no longer receive any calls to OnDisconnected().

Any help/guidance on changes to behaviour of ReconnectAndRejoin() are appreciated.

Best Answer

Answers

  • Thank you Simon
  • Maheshk_218
    edited December 2018
    Options
    Hi @Christian_Simon

    We have integrated PUN for one of our game. We are facing some issues related to internet connection.
    Player 1 and Player2 connected in one of the PvP game. Some time later Player 1 lost internet connection for 3 seconds and came back. Player2 got an event immediately after player1 lost connection, but player1 didn't received any event related to failure connection immediately (Received after 60 sec), and for player1 still showing connected TRUE.
    Other issues is even after player1 got internet connection , message passing is not happening between two players.
    Could some one guide on fixing this.

    Should we go for PUN2 ?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Maheshk_218,

    You can find an answer here.