Example #1
0
    protected void Update()
    {
        ExitGames.Client.Photon.LoadBalancing.LoadBalancingPeer voicePeer = PhotonVoiceNetwork.Client.loadBalancingPeer;
        if (voicePeer == null)
        {
            UnityEngine.Debug.LogError("[PUNVoice]: LoadBalancingPeer broke!");
            return;
        }

        ExitGames.Client.Photon.LoadBalancing.ClientState clientState = PhotonVoiceNetwork.Client.State;
        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)
        {
            return;
        }

        bool doDispatch = true;

        while (PhotonNetwork.isMessageQueueRunning && doDispatch)
        {
            // DispatchIncomingCommands() returns true of it found any command to dispatch (event, result or state change)
            Profiler.BeginSample("[PUNVoice]: DispatchIncomingCommands");
            doDispatch = voicePeer.DispatchIncomingCommands();
            Profiler.EndSample();
        }

        int currentMsSinceStart = (int)(Time.realtimeSinceStartup * 1000); // avoiding Environment.TickCount, which could be negative on long-running platforms

        if (currentMsSinceStart > nextSendTickCount)
        {
            bool doSend = true;
            while (PhotonNetwork.isMessageQueueRunning && doSend)
            {
                // Send all outgoing commands
                Profiler.BeginSample("[PUNVoice]: SendOutgoingCommands");
                doSend = voicePeer.SendOutgoingCommands();
                Profiler.EndSample();
            }

            nextSendTickCount = currentMsSinceStart + updateInterval;
        }
    }
Example #2
0
    // Token: 0x06000028 RID: 40 RVA: 0x00002B54 File Offset: 0x00000D54
    protected void Update()
    {
        ExitGames.Client.Photon.LoadBalancing.LoadBalancingPeer loadBalancingPeer = PhotonVoiceNetwork.Client.loadBalancingPeer;
        if (loadBalancingPeer == null)
        {
            Debug.LogError("[PUNVoice]: LoadBalancingPeer broke!");
            return;
        }
        ExitGames.Client.Photon.LoadBalancing.ClientState state = PhotonVoiceNetwork.Client.State;
        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)
        {
            return;
        }
        bool flag2 = true;

        while (PhotonNetwork.isMessageQueueRunning && flag2)
        {
            flag2 = loadBalancingPeer.DispatchIncomingCommands();
        }
        int num = (int)(Time.realtimeSinceStartup * 1000f);

        if (num > this.nextSendTickCount)
        {
            bool flag3 = true;
            while (PhotonNetwork.isMessageQueueRunning && flag3)
            {
                flag3 = loadBalancingPeer.SendOutgoingCommands();
            }
            this.nextSendTickCount = num + this.updateInterval;
        }
    }