aspnetcore/src/Kestrel.Transport.Abstractions/Internal/TransportConnection.cs

59 lines
1.9 KiB
C#

using System.Buffers;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Net;
using System.Threading;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
{
public abstract partial class TransportConnection : ConnectionContext
{
private IDictionary<object, object> _items;
public TransportConnection()
{
_currentIConnectionIdFeature = this;
_currentIConnectionTransportFeature = this;
_currentIHttpConnectionFeature = this;
_currentIConnectionItemsFeature = this;
_currentIApplicationTransportFeature = this;
_currentIMemoryPoolFeature = this;
_currentITransportSchedulerFeature = this;
}
public IPAddress RemoteAddress { get; set; }
public int RemotePort { get; set; }
public IPAddress LocalAddress { get; set; }
public int LocalPort { get; set; }
public override string ConnectionId { get; set; }
public override IFeatureCollection Features => this;
public virtual MemoryPool<byte> MemoryPool { get; }
public virtual PipeScheduler InputWriterScheduler { get; }
public virtual PipeScheduler OutputReaderScheduler { get; }
public override IDuplexPipe Transport { get; set; }
public IDuplexPipe Application { get; set; }
public override IDictionary<object, object> Items
{
get
{
// Lazily allocate connection metadata
return _items ?? (_items = new ConnectionItems());
}
set
{
_items = value;
}
}
public PipeWriter Input => Application.Output;
public PipeReader Output => Application.Input;
}
}