示例#1
0
 // Token: 0x06000025 RID: 37 RVA: 0x00002A18 File Offset: 0x00000C18
 private static bool FallbackSendAckThread()
 {
     if (PhotonVoiceHandler.sendThreadShouldRun && PhotonVoiceNetwork.Client != null && PhotonVoiceNetwork.Client.loadBalancingPeer != null)
     {
         ExitGames.Client.Photon.LoadBalancing.LoadBalancingPeer loadBalancingPeer = PhotonVoiceNetwork.Client.loadBalancingPeer;
         ExitGames.Client.Photon.LoadBalancing.ClientState       state             = PhotonVoiceNetwork.Client.State;
         if (PhotonVoiceHandler.timerToStopConnectionInBackground != null && PhotonVoiceNetwork.BackgroundTimeout > 0.1f && (float)PhotonVoiceHandler.timerToStopConnectionInBackground.ElapsedMilliseconds > PhotonVoiceNetwork.BackgroundTimeout * 1000f)
         {
             bool flag = true;
             if (state == ExitGames.Client.Photon.LoadBalancing.ClientState.PeerCreated || state - ExitGames.Client.Photon.LoadBalancing.ClientState.Disconnecting <= 1 || state == ExitGames.Client.Photon.LoadBalancing.ClientState.ConnectedToNameServer)
             {
                 flag = false;
             }
             if (flag)
             {
                 PhotonVoiceNetwork.Disconnect();
             }
             PhotonVoiceHandler.timerToStopConnectionInBackground.Stop();
             PhotonVoiceHandler.timerToStopConnectionInBackground.Reset();
             return(PhotonVoiceHandler.sendThreadShouldRun);
         }
         if (loadBalancingPeer.ConnectionTime - loadBalancingPeer.LastSendOutgoingTime > 200)
         {
             loadBalancingPeer.SendAcksOnly();
         }
     }
     return(PhotonVoiceHandler.sendThreadShouldRun);
 }
示例#2
0
    /// <summary>A thread which runs independent from the Update() calls. Keeps connections online while loading or in background. See PhotonVoiceNetwork.BackgroundTimeout.</summary>
    private static bool FallbackSendAckThread()
    {
        if (sendThreadShouldRun && PhotonVoiceNetwork.Client != null && PhotonVoiceNetwork.Client.loadBalancingPeer != null)
        {
            ExitGames.Client.Photon.LoadBalancing.LoadBalancingPeer voicePeer   = PhotonVoiceNetwork.Client.loadBalancingPeer;
            ExitGames.Client.Photon.LoadBalancing.ClientState       clientState = PhotonVoiceNetwork.Client.State;
            // check if the client should disconnect after some seconds in background
            if (timerToStopConnectionInBackground != null && PhotonVoiceNetwork.BackgroundTimeout > 0.1f)
            {
                if (timerToStopConnectionInBackground.ElapsedMilliseconds > PhotonVoiceNetwork.BackgroundTimeout * 1000)
                {
                    bool connected = true;
                    switch (clientState)
                    {
                    case ExitGames.Client.Photon.LoadBalancing.ClientState.PeerCreated:
                    case ExitGames.Client.Photon.LoadBalancing.ClientState.Disconnected:
                    case ExitGames.Client.Photon.LoadBalancing.ClientState.Disconnecting:
                    case ExitGames.Client.Photon.LoadBalancing.ClientState.ConnectedToNameServer:
                        connected = false;
                        break;
                    }
                    if (connected)
                    {
                        PhotonVoiceNetwork.Disconnect();
                    }
                    timerToStopConnectionInBackground.Stop();
                    timerToStopConnectionInBackground.Reset();
                    return(sendThreadShouldRun);
                }
            }

            if (voicePeer.ConnectionTime - voicePeer.LastSendOutgoingTime > 200)
            {
                voicePeer.SendAcksOnly();
            }
        }

        return(sendThreadShouldRun);
    }