How to continue a chess like turn based game once internet connection is disconnected and connected
Options
I have implemented photon's Pun Solution for multiplayer in my Unity3d game and it is working fine except when I intentionally turn off my phone's data for few seconds and then turn it back on, the Player game object with PhotonView that I instantiated over the network destroys. Now I want a functionality where I can reconnect my player once internet connection is restored.
I am aware that using PhotonNetwork.ReconnectAndRejoin() connects the client to server back to server and then using PhotonNetwork.JoinRoom(LobbyController.RoomName) I can get connected back to the previous room. But the issue is how am I suppose to handle the player prefabs which were instantiated over the Photon network if I locally instantiate them then PhotonView has 0 as Id. Do I need to instantiate the Prefabs over the network again once internet connection is back? Please correct me if I misunderstood some functionality.
For checking internet I am using recursion, once internet is restored I reconnect and rejoin the room, I cached the room name.
I am aware that using PhotonNetwork.ReconnectAndRejoin() connects the client to server back to server and then using PhotonNetwork.JoinRoom(LobbyController.RoomName) I can get connected back to the previous room. But the issue is how am I suppose to handle the player prefabs which were instantiated over the Photon network if I locally instantiate them then PhotonView has 0 as Id. Do I need to instantiate the Prefabs over the network again once internet connection is back? Please correct me if I misunderstood some functionality.
For checking internet I am using recursion, once internet is restored I reconnect and rejoin the room, I cached the room name.
public void CheckIfInternetIsBackOn() { if (Application.internetReachability == NetworkReachability.NotReachable) Invoke("CheckIfInternetIsBackOn", 1); else { print("Reconnecting and rejoining"); PhotonNetwork.ReconnectAndRejoin(); PhotonNetwork.JoinRoom(LobbyController.RoomName); } }
0
Answers
This discussion has been closed.