Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ReconnectController : MonoBehaviourPunCallbacks
- {
- private IEnumerator MainReconnect()
- {
- while (PhotonNetwork.NetworkingClient.LoadBalancingPeer.PeerState != ExitGames.Client.Photon.PeerStateValue.Disconnected)
- {
- Debug.Log("Waiting for client to be fully disconnected..", this);
- yield return new WaitForSeconds(0.2f);
- }
- Debug.Log("Client is disconnected!", this);
- if (!PhotonNetwork.ReconnectAndRejoin())
- {
- if (PhotonNetwork.Reconnect())
- {
- Debug.Log("Successful reconnected!", this);
- }
- }
- else
- {
- Debug.Log("Successful reconnected and joined!", this);
- }
- }
- public override void OnDisconnected(DisconnectCause cause)
- {
- StartCoroutine(MainReconnect());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement