/// <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); } } }
/// <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(); }