public void LastmileQuality(AgoraRtcEngineKit engine, NetworkQuality agoraQuality)
        {
            string quality = string.Empty;

            switch (agoraQuality)
            {
            case NetworkQuality.Excellent:
                quality = "Excellent";
                ConnectionImage.Image = UIImage.FromBundle("connection_5");
                break;

            case NetworkQuality.Good:
                quality = "Good";
                ConnectionImage.Image = UIImage.FromBundle("connection_4");
                break;

            case NetworkQuality.Poor:
                quality = "Poor";
                ConnectionImage.Image = UIImage.FromBundle("connection_3");
                break;

            case NetworkQuality.Bad:
                quality = "Bad";
                ConnectionImage.Image = UIImage.FromBundle("connection_2");
                break;

            case NetworkQuality.VBad:
                quality = "Very Bad";
                ConnectionImage.Image = UIImage.FromBundle("connection_1");
                break;

            case NetworkQuality.Down:
                quality = "Down";
                ConnectionImage.Image = UIImage.FromBundle("connection_0");
                break;

            default:
                quality = "Unknown";
                ConnectionImage.Image = UIImage.FromBundle("connection_0");
                break;
            }
            ConnectingLabel.Text = string.Format(QualityFormat, quality);
        }
        /// <summary>
        /// Updates the latency and packet loss simulation options. Only the
        /// host can alter these values, which are then synchronized over the
        /// network by storing them into NetworkSession.SessionProperties. Any
        /// changes to the SessionProperties data are automatically replicated
        /// on all the client machines, so there is no need to manually send
        /// network packets to transmit this data.
        /// </summary>
        void UpdateOptions()
        {
            if (networkSession.IsHost)
            {
                // Change the network quality simultation?
                if (IsPressed(Keys.A, Buttons.A))
                {
                    networkQuality++;

                    if (networkQuality > NetworkQuality.Perfect)
                        networkQuality = 0;
                }

                // Change the packet send rate?
                if (IsPressed(Keys.B, Buttons.B))
                {
                    if (framesBetweenPackets == 6)
                        framesBetweenPackets = 3;
                    else if (framesBetweenPackets == 3)
                        framesBetweenPackets = 1;
                    else
                        framesBetweenPackets = 6;
                }

                // Toggle prediction on or off?
                if (IsPressed(Keys.X, Buttons.X))
                    enablePrediction = !enablePrediction;

                // Toggle smoothing on or off?
                if (IsPressed(Keys.Y, Buttons.Y))
                    enableSmoothing = !enableSmoothing;

                // Stores the latest settings into NetworkSession.SessionProperties.
                networkSession.SessionProperties[0] = (int)networkQuality;
                networkSession.SessionProperties[1] = framesBetweenPackets;
                networkSession.SessionProperties[2] = enablePrediction ? 1 : 0;
                networkSession.SessionProperties[3] = enableSmoothing ? 1 : 0;
            }
            else
            {
                // Client machines read the latest settings from the session properties.
                networkQuality = (NetworkQuality)networkSession.SessionProperties[0];
                framesBetweenPackets = networkSession.SessionProperties[1].Value;
                enablePrediction = networkSession.SessionProperties[2] != 0;
                enableSmoothing = networkSession.SessionProperties[3] != 0;
            }

            // Update the SimulatedLatency and SimulatedPacketLoss properties.
            switch (networkQuality)
            {
                case NetworkQuality.Typical:
                    networkSession.SimulatedLatency = TimeSpan.FromMilliseconds(100);
                    networkSession.SimulatedPacketLoss = 0.1f;
                    break;

                case NetworkQuality.Poor:
                    networkSession.SimulatedLatency = TimeSpan.FromMilliseconds(200);
                    networkSession.SimulatedPacketLoss = 0.2f;
                    break;

                case NetworkQuality.Perfect:
                    networkSession.SimulatedLatency = TimeSpan.Zero;
                    networkSession.SimulatedPacketLoss = 0;
                    break;
            }
        }
示例#3
0
        /// <summary>
        /// Updates the latency and packet loss simulation options. Only the
        /// host can alter these values, which are then synchronized over the
        /// network by storing them into NetworkSession.SessionProperties. Any
        /// changes to the SessionProperties data are automatically replicated
        /// on all the client machines, so there is no need to manually send
        /// network packets to transmit this data.
        /// </summary>
        void UpdateOptions()
        {
            if (networkSession.IsHost)
            {
                // Change the network quality simultation?
                if (IsPressed(Keys.A, Buttons.A))
                {
                    networkQuality++;

                    if (networkQuality > NetworkQuality.Perfect)
                    {
                        networkQuality = 0;
                    }
                }

                // Change the packet send rate?
                if (IsPressed(Keys.B, Buttons.B))
                {
                    if (framesBetweenPackets == 6)
                    {
                        framesBetweenPackets = 3;
                    }
                    else if (framesBetweenPackets == 3)
                    {
                        framesBetweenPackets = 1;
                    }
                    else
                    {
                        framesBetweenPackets = 6;
                    }
                }

                // Toggle prediction on or off?
                if (IsPressed(Keys.X, Buttons.X))
                {
                    enablePrediction = !enablePrediction;
                }

                // Toggle smoothing on or off?
                if (IsPressed(Keys.Y, Buttons.Y))
                {
                    enableSmoothing = !enableSmoothing;
                }

                // Stores the latest settings into NetworkSession.SessionProperties.
                networkSession.SessionProperties[0] = (int)networkQuality;
                networkSession.SessionProperties[1] = framesBetweenPackets;
                networkSession.SessionProperties[2] = enablePrediction ? 1 : 0;
                networkSession.SessionProperties[3] = enableSmoothing ? 1 : 0;
            }
            else
            {
                // Client machines read the latest settings from the session properties.
                networkQuality       = (NetworkQuality)networkSession.SessionProperties[0];
                framesBetweenPackets = networkSession.SessionProperties[1].Value;
                enablePrediction     = networkSession.SessionProperties[2] != 0;
                enableSmoothing      = networkSession.SessionProperties[3] != 0;
            }

            // Update the SimulatedLatency and SimulatedPacketLoss properties.
            switch (networkQuality)
            {
            case NetworkQuality.Typical:
                networkSession.SimulatedLatency    = TimeSpan.FromMilliseconds(100);
                networkSession.SimulatedPacketLoss = 0.1f;
                break;

            case NetworkQuality.Poor:
                networkSession.SimulatedLatency    = TimeSpan.FromMilliseconds(200);
                networkSession.SimulatedPacketLoss = 0.2f;
                break;

            case NetworkQuality.Perfect:
                networkSession.SimulatedLatency    = TimeSpan.Zero;
                networkSession.SimulatedPacketLoss = 0;
                break;
            }
        }
示例#4
0
 public override void LastmileQuality(AgoraRtcEngineKit engine, NetworkQuality quality)
 {
     _controller.LastmileQuality(engine, quality);
 }
示例#5
0
        private void UpdateOptions()
        {
            if (_networkSession.IsHost) {
                if (IsPressed(Keys.U)) {
                    _networkQuality++;

                    if (_networkQuality > NetworkQuality.Perfect)
                        _networkQuality = 0;
                }

                if (IsPressed(Keys.I)) {
                    if (_framesBetweenPackets == 6)
                        _framesBetweenPackets = 3;
                    else if (_framesBetweenPackets == 3)
                        _framesBetweenPackets = 1;
                    else
                        _framesBetweenPackets = 6;
                }

                if (IsPressed(Keys.O))
                    _enablePrediction = !_enablePrediction;

                if (IsPressed(Keys.P))
                    _enableSmoothing = !_enableSmoothing;

                _networkSession.SessionProperties[0] = (int)_networkQuality;
                _networkSession.SessionProperties[1] = _framesBetweenPackets;
                _networkSession.SessionProperties[2] = _enablePrediction ? 1 : 0;
                _networkSession.SessionProperties[3] = _enableSmoothing ? 1 : 0;
            } else {
                if (_networkSession.SessionProperties[0] != null)
                    _networkQuality = (NetworkQuality)_networkSession.SessionProperties[0];
                if (_networkSession.SessionProperties[1] != null)
                    _framesBetweenPackets = _networkSession.SessionProperties[1].Value;
                if (_networkSession.SessionProperties[2] != null)
                    _enablePrediction = _networkSession.SessionProperties[2] != 0;
                if (_networkSession.SessionProperties[3] != null)
                    _enableSmoothing = _networkSession.SessionProperties[3] != 0;
            }

            switch (_networkQuality) {
            case NetworkQuality.Typical:
                _networkSession.SimulatedLatency = TimeSpan.FromMilliseconds(100);
                _networkSession.SimulatedPacketLoss = 0.1f;
                break;
            case NetworkQuality.Poor:
                _networkSession.SimulatedLatency = TimeSpan.FromMilliseconds(200);
                _networkSession.SimulatedPacketLoss = 0.2f;
                break;

            case NetworkQuality.Perfect:
                _networkSession.SimulatedLatency = TimeSpan.Zero;
                _networkSession.SimulatedPacketLoss = 0;
                break;

            }
        }