Disconnect() 공개 메소드

Disconnects the specified Mx client. This removes it from the group that owns it, and prevents it from reconnecting to this dispatcher implicitly.
public Disconnect ( MxClient client ) : void
client MxClient The client.
리턴 void
예제 #1
0
        /// <summary>
        /// Isolates the group to use only one, connected Mx client, and disconnects
        /// the rest.
        /// </summary>
        public void Isolate()
        {
            if (RealtimeClients.Count == 0)
            {
                return;
            }

            var selectedClient = RealtimeClients.First(x => x.HasReceivedPacket);

            foreach (var client in RealtimeClients.ToArray())
            {
                if (!client.Endpoint.Equals(selectedClient.Endpoint))
                {
                    _dispatcher.Disconnect(client);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Updates the state of the Mx client, sending outgoing packets and receiving incoming packets.
        /// </summary>
        public void Update()
        {
            _deltaTime = (DateTime.Now - _lastCall).TotalMilliseconds;
            _lastCall  = DateTime.Now;

            if (_disconnectAccumulator > _disconnectWarningLimit)
            {
                OnDisconnectWarning(
                    new MxDisconnectEventArgs
                {
                    Client = this,
                    DisconnectAccumulator = _disconnectAccumulator,
                    DisconnectTimeout     = _disconnectLimit,
                    IsDisconnected        = _disconnectAccumulator > _disconnectLimit
                });
            }

            if (_disconnectAccumulator > _disconnectLimit)
            {
                _dispatcher.Disconnect(this);
                return;
            }

            UpdateFlowControl();

            foreach (var kv in _sendQueue.ToArray())
            {
                var idx = kv.Key;

                if (GetUnixTimestamp() - kv.Value > 1000)
                {
                    HandleLostMessage(idx);
                }
            }

            PerformSend();

            PerformReceive();
        }