private async Task HubOnDisconnectedAsync(HubConnectionContext connection, Exception exception) { // send close message before aborting the connection await SendCloseAsync(connection, exception); // We wait on abort to complete, this is so that we can guarantee that all callbacks have fired // before OnDisconnectedAsync try { // Ensure the connection is aborted before firing disconnect await connection.AbortAsync(); } catch (Exception ex) { Log.AbortFailed(_logger, ex); } try { await _dispatcher.OnDisconnectedAsync(connection, exception); } catch (Exception ex) { Log.ErrorDispatchingHubEvent(_logger, "OnDisconnectedAsync", ex); throw; } }
public async Task AbortAsync() { _checkTimeoutTimer.Dispose(); try { var clientTasks = State.ConnectionIds.Select(id => GrainFactory.GetClientGrain(id, _hubTypeId).OnDisconnectedAsync()); await Task.WhenAll(clientTasks); } catch (Exception ex) { Log.AbortFailed(_logger, ex); } State.Aborted = true; DeactivateOnIdle(); }