"photon engine timeout" Code Answer's

You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "photon engine timeout" answered properly. Developers are finding an appropriate answer about photon engine timeout related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like photon engine timeout. Enter your desired code related query in the search bar and get every piece of information about C# code related question on photon engine timeout. 

photon engine timeout

By Inexpensive ImpalaInexpensive Impala on Nov 26, 2020
using System;
using Photon.Realtime;

public class RecoverFromUnexpectedDisconnectSample : IConnectionCallbacks
{
    private LoadBalancingClient loadBalancingClient;
    private AppSettings appSettings;

    public RecoverFromUnexpectedDisconnectSample(LoadBalancingClient loadBalancingClient, AppSettings appSettings)
    {
        this.loadBalancingClient = loadBalancingClient;
        this.appSettings = appSettings;
        this.loadBalancingClient.AddCallbackTarget(this);
    }

    ~RecoverFromUnexpectedDisconnectSample()
    {
        this.loadBalancingClient.RemoveCallbackTarget(this);
    }

    void IConnectionCallbacks.OnDisconnected(DisconnectCause cause)
    {
        if (this.CanRecoverFromDisconnect(cause))
        {
            this.Recover();
        }
    }

    private bool CanRecoverFromDisconnect(DisconnectCause cause)
    {
        switch (cause)
        {
            // the list here may be non exhaustive and is subject to review
            case DisconnectCause.Exception:
            case DisconnectCause.ServerTimeout:
            case DisconnectCause.ClientTimeout:
            case DisconnectCause.DisconnectByServerLogic:
            case DisconnectCause.DisconnectByServerReasonUnknown:
                return true;
        }
        return false;
    }

    private void Recover()
    {
        if (!loadBalancingClient.ReconnectAndRejoin())
        {
            Debug.LogError("ReconnectAndRejoin failed, trying Reconnect");
            if (!loadBalancingClient.ReconnectToMaster())
            {
                Debug.LogError("Reconnect failed, trying ConnectUsingSettings");
                if (!loadBalancingClient.ConnectUsingSettings(appSettings))
                {
                    Debug.LogError("ConnectUsingSettings failed");
                }
            }
        }
    }

    #region Unused Methods

    void IConnectionCallbacks.OnConnected()
    {
    }

    void IConnectionCallbacks.OnConnectedToMaster()
    {
    }

    void IConnectionCallbacks.OnRegionListReceived(RegionHandler regionHandler)
    {
    }

    void IConnectionCallbacks.OnCustomAuthenticationResponse(Dictionary<string, object> data)
    {
    }

    void IConnectionCallbacks.OnCustomAuthenticationFailed(string debugMessage)
    {
    }

    #endregion
}

Source: doc.photonengine.com

Add Comment

0

All those coders who are working on the C# based application and are stuck on photon engine timeout can get a collection of related answers to their query. Programmers need to enter their query on photon engine timeout related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about photon engine timeout for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of photon engine timeout while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "photon engine timeout". Visit this developer's friendly online web community, CodeProZone, and get your queries like photon engine timeout resolved professionally and stay updated to the latest C# updates. 

C# answers related to "photon engine timeout"

View All C# queries

C# queries related to "photon engine timeout"

Browse Other Code Languages

CodeProZone