public override async Task OnDisconnectedAsync(HubConnectionContext connection) { await _wrappedHubLifetimeManager.OnDisconnectedAsync(connection); _connections.Remove(connection); await _userTracker.RemoveUser(connection); }
public override async Task OnDisconnectedAsync(HubConnectionContext connection) { await _wrappedHubLifetimeManager.OnDisconnectedAsync(connection); _logger.LogCritical($"OnDisconnectedAsync : {connection.ConnectionId }"); _connections.Remove(connection); await _userTracker.RemoveUser(connection); }
public override async Task OnDisconnectedAsync(HubConnectionContext connection) { await _wrappedHubLifetimeManager.OnDisconnectedAsync(connection); _connections.Remove(connection); var users = await _userTracker.UsersOnline(); var user = users.Where(t => t.ConnectionId == connection.ConnectionId).FirstOrDefault(); await _userTracker.RemoveUser(connection, user.PushToken.Any(t => t.Device != "desktop")); }
/// <inheritdoc /> public override async Task OnConnectedAsync(ConnectionContext connection) { // We check to see if HubOptions<THub> are set because those take precedence over global hub options. // Then set the keepAlive and handshakeTimeout values to the defaults in HubOptionsSetup when they were explicitly set to null. var supportedProtocols = _hubOptions.SupportedProtocols ?? _globalHubOptions.SupportedProtocols; if (supportedProtocols == null || supportedProtocols.Count == 0) { throw new InvalidOperationException("There are no supported protocols"); } var handshakeTimeout = _hubOptions.HandshakeTimeout ?? _globalHubOptions.HandshakeTimeout ?? HubOptionsSetup.DefaultHandshakeTimeout; var contextOptions = new HubConnectionContextOptions() { KeepAliveInterval = _hubOptions.KeepAliveInterval ?? _globalHubOptions.KeepAliveInterval ?? HubOptionsSetup.DefaultKeepAliveInterval, ClientTimeoutInterval = _hubOptions.ClientTimeoutInterval ?? _globalHubOptions.ClientTimeoutInterval ?? HubOptionsSetup.DefaultClientTimeoutInterval, StreamBufferCapacity = _hubOptions.StreamBufferCapacity ?? _globalHubOptions.StreamBufferCapacity ?? HubOptionsSetup.DefaultStreamBufferCapacity, MaximumReceiveMessageSize = _maximumMessageSize, SystemClock = SystemClock, MaximumParallelInvocations = _maxParallelInvokes, }; Log.ConnectedStarting(_logger); var connectionContext = new HubConnectionContext(connection, contextOptions, _loggerFactory); var resolvedSupportedProtocols = (supportedProtocols as IReadOnlyList <string>) ?? supportedProtocols.ToList(); if (!await connectionContext.HandshakeAsync(handshakeTimeout, resolvedSupportedProtocols, _protocolResolver, _userIdProvider, _enableDetailedErrors)) { return; } // -- the connectionContext has been set up -- try { await _lifetimeManager.OnConnectedAsync(connectionContext); await RunHubAsync(connectionContext); } finally { connectionContext.Cleanup(); Log.ConnectedEnding(_logger); await _lifetimeManager.OnDisconnectedAsync(connectionContext); } }