protected override Task OnClientConnectedAsync(OpenConnectionMessage message) { var connection = _clientConnectionFactory.CreateConnection(message, ConfigureContext); connection.ServiceConnection = this; if (message.Headers.TryGetValue(Constants.AsrsMigrateFrom, out var from)) { connection.Features.Set <IConnectionMigrationFeature>(new ConnectionMigrationFeature(from, ServerId)); } AddClientConnection(connection, message); _ = ProcessClientConnectionAsync(connection); if (connection.IsMigrated) { Log.MigrationStarting(Logger, connection.ConnectionId); } else { Log.ConnectedStarting(Logger, connection.ConnectionId); } return(Task.CompletedTask); }
protected override Task OnConnectedAsync(OpenConnectionMessage message) { var connection = _clientConnectionFactory.CreateConnection(message); AddClientConnection(connection); Log.ConnectedStarting(_logger, connection.ConnectionId); // Execute the application code connection.ApplicationTask = _connectionDelegate(connection); // Writing from the application to the service _ = ProcessOutgoingMessagesAsync(connection); // Waiting for the application to shutdown so we can clean up the connection _ = WaitOnApplicationTask(connection); return(Task.CompletedTask); }
protected override Task OnClientConnectedAsync(OpenConnectionMessage message) { var connection = _clientConnectionFactory.CreateConnection(message, ConfigureContext); connection.ServiceConnection = this; if (message.Headers.TryGetValue(Constants.AsrsMigrateFrom, out var from)) { connection.Features.Set <IConnectionMigrationFeature>(new ConnectionMigrationFeature(from, ServerId)); } AddClientConnection(connection, message); bool isDiagnosticClient = false; message.Headers.TryGetValue(Constants.AsrsIsDiagnosticClient, out var isDiagnosticClientValue); if (!StringValues.IsNullOrEmpty(isDiagnosticClientValue)) { isDiagnosticClient = Convert.ToBoolean(isDiagnosticClientValue.FirstOrDefault()); } using (new ClientConnectionScope(endpoint: HubEndpoint, outboundConnection: this, isDiagnosticClient: isDiagnosticClient)) { _ = ProcessClientConnectionAsync(connection); } if (connection.IsMigrated) { Log.MigrationStarting(Logger, connection.ConnectionId); } else { Log.ConnectedStarting(Logger, connection.ConnectionId); } return(Task.CompletedTask); }
protected override Task OnClientConnectedAsync(OpenConnectionMessage message) { var connection = _clientConnectionFactory.CreateConnection(message, ConfigureContext); connection.ServiceConnection = this; // Execute the application code connection.ApplicationTask = ProcessApplicationTaskAsync(connection); connection.LifetimeTask = ProcessClientConnectionAsync(connection); AddClientConnection(connection, message); if (connection.IsMigrated) { Log.MigrationStarting(Logger, connection.ConnectionId); } else { Log.ConnectedStarting(Logger, connection.ConnectionId); } return(Task.CompletedTask); }