Пример #1
0
        /// <summary>
        /// Handles a client's stage changed event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ResonanceComponentStateChangedEventArgs"/> instance containing the event data.</param>
        private void OnClientStateChanged(object sender, ResonanceComponentStateChangedEventArgs e)
        {
            ResonanceSignalRClient client = sender as ResonanceSignalRClient;

            if (e.NewState == ResonanceComponentState.Failed)
            {
                Logger.LogWarning($"Client {client.RemoteAdapterInformation.Name} disconnected.");

                InvokeUI(() =>
                {
                    Clients.Remove(client);
                });
            }
        }
Пример #2
0
        private void TargetTransporter_StateChanged(object sender, ResonanceComponentStateChangedEventArgs e)
        {
            if (e.NewState == ResonanceComponentState.Failed && DisconnectOnFailure && SourceTransporter.State == ResonanceComponentState.Connected)
            {
                Task.Factory.StartNew(async() =>
                {
                    Logger.LogInformation("Target transporter has failed. disconnecting target transporter...");

                    try
                    {
                        await SourceTransporter.DisconnectAsync($"The remote routed target transporter has failed: {TargetTransporter.FailedStateException.Message}.");
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(ex, "Error occurred while trying to disconnect the source transporter.");
                    }
                });
            }
        }
Пример #3
0
        /// <summary>
        /// Handles a client's stage changed event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ResonanceComponentStateChangedEventArgs"/> instance containing the event data.</param>
        private async void OnClientStateChanged(object sender, ResonanceComponentStateChangedEventArgs e)
        {
            ResonanceTcpClient client = sender as ResonanceTcpClient;

            if (e.NewState == ResonanceComponentState.Failed)
            {
                Logger.LogWarning($"Client {client.ClientID} disconnected.");

                _clients.Remove(client);

                UpdateClientsList();

                if (client.InSession)
                {
                    client.RemoteClient.InSession = false;
                    await client.RemoteClient.SendAsync(new LeaveSessionRequest()
                    {
                        Reason = "The remote client has disconnected"
                    });
                }
            }
        }