/
BaseConnectionContext.cs
65 lines (55 loc) · 2.34 KB
/
BaseConnectionContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.Connections
{
public abstract class BaseConnectionContext : IAsyncDisposable
{
/// <summary>
/// Gets or sets a unique identifier to represent this connection in trace logs.
/// </summary>
public abstract string ConnectionId { get; set; }
/// <summary>
/// Gets the collection of features provided by the server and middleware available on this connection.
/// </summary>
public abstract IFeatureCollection Features { get; }
/// <summary>
/// Gets or sets a key/value collection that can be used to share data within the scope of this connection.
/// </summary>
public abstract IDictionary<object, object?> Items { get; set; }
/// <summary>
/// Triggered when the client connection is closed.
/// </summary>
public virtual CancellationToken ConnectionClosed { get; set; }
/// <summary>
/// Gets or sets the local endpoint for this connection.
/// </summary>
public virtual EndPoint? LocalEndPoint { get; set; }
/// <summary>
/// Gets or sets the remote endpoint for this connection.
/// </summary>
public virtual EndPoint? RemoteEndPoint { get; set; }
/// <summary>
/// Aborts the underlying connection.
/// </summary>
public abstract void Abort();
/// <summary>
/// Aborts the underlying connection.
/// </summary>
/// <param name="abortReason">An optional <see cref="ConnectionAbortedException"/> describing the reason the connection is being terminated.</param>
public abstract void Abort(ConnectionAbortedException abortReason);
/// <summary>
/// Releases resources for the underlying connection.
/// </summary>
/// <returns>A <see cref="ValueTask"/> that completes when resources have been released.</returns>
public virtual ValueTask DisposeAsync()
{
return default;
}
}
}