예제 #1
0
 public async Task StopAsync(CancellationToken cancellationToken)
 {
     if (Connection.State != HubConnectionState.Disconnected)
     {
         await _client.StopAsync(cancellationToken);
     }
 }
        /// <summary>
        /// Disposes component resources asynchronously.
        /// </summary>
        /// <returns></returns>
        public async Task DisposeAsync()
        {
            if (!IsDisposed)
            {
                try
                {
                    await UnregisterAsync();
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex, "Error occurred while disposing the registered service. Unregister service failed.");
                }

                IsDisposed = true;
                await _client?.StopAsync();

                await _client?.DisposeAsync();

                _client = null;
            }
        }
예제 #3
0
        /// <summary>
        /// Called when the adapter is disconnecting.
        /// </summary>
        /// <param name="notify">if set to <c>true</c> to notify the other side about the disconnection.</param>
        private async Task OnDisconnect(bool notify)
        {
            try
            {
                if (notify)
                {
                    await _client.InvokeAsync(ResonanceHubMethods.Disconnect);
                }
                await _client.StopAsync();

                await _client.DisposeAsync();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, $"Error occurred while disconnecting.");
            }

            Logger.LogInformation("Disconnected.");

            if (!notify && !IsFailing)
            {
                OnFailed(new RemoteAdapterDisconnectedException(), "The remote SignalR adapter has disconnected.");
            }
        }