// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.IO.Pipelines; using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Http.Features; namespace Microsoft.AspNetCore.Connections { public abstract class ConnectionContext { public abstract string ConnectionId { get; set; } public abstract IFeatureCollection Features { get; } public abstract IDictionary Items { get; set; } public abstract IDuplexPipe Transport { get; set; } public virtual void Abort(ConnectionAbortedException abortReason) { // We expect this to be overridden, but this helps maintain back compat // with implementations of ConnectionContext that predate the addition of // ConnectioContext.Abort() Features.Get()?.Abort(); } public virtual void Abort() => Abort(new ConnectionAbortedException("The connection was aborted by the application.")); } }