3 types derived from HubConnectionContext
Microsoft.AspNetCore.SignalR.Microbenchmarks (1)
DefaultHubDispatcherBenchmark.cs (1)
83public class NoErrorHubConnectionContext : HubConnectionContext
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
src\SignalR\common\testassets\Tests.Utils\HubConnectionContextUtils.cs (1)
42public class MockHubConnectionContext : HubConnectionContext
Microsoft.AspNetCore.SignalR.Tests.Utils (1)
HubConnectionContextUtils.cs (1)
42public class MockHubConnectionContext : HubConnectionContext
6 instantiations of HubConnectionContext
Microsoft.AspNetCore.SignalR.Core (1)
HubConnectionHandler.cs (1)
134var connectionContext = new HubConnectionContext(connection, contextOptions, _loggerFactory)
Microsoft.AspNetCore.SignalR.Microbenchmarks (3)
BroadcastBenchmark.cs (1)
50var hubConnection = new HubConnectionContext(connection, contextOptions, NullLoggerFactory.Instance);
DefaultHubLifetimeManagerBenchmark.cs (1)
55var hubConnectionContext = new HubConnectionContext(connectionContext, contextOptions, NullLoggerFactory.Instance);
HubConnectionContextBenchmark.cs (1)
46_hubConnectionContext = new HubConnectionContext(connection, contextOptions, NullLoggerFactory.Instance);
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
src\SignalR\common\testassets\Tests.Utils\HubConnectionContextUtils.cs (1)
24return new HubConnectionContext(connection, contextOptions, NullLoggerFactory.Instance)
Microsoft.AspNetCore.SignalR.Tests.Utils (1)
HubConnectionContextUtils.cs (1)
24return new HubConnectionContext(connection, contextOptions, NullLoggerFactory.Instance)
182 references to HubConnectionContext
Microsoft.AspNetCore.SignalR (1)
GetHttpContextExtensions.cs (1)
30public static HttpContext? GetHttpContext(this HubConnectionContext connection)
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (1)
HeaderUserIdProvider.cs (1)
10public string GetUserId(HubConnectionContext connection)
Microsoft.AspNetCore.SignalR.Core (76)
DefaultHubLifetimeManager.cs (10)
39var connection = _connections[connectionId]; 72var connection = _connections[connectionId]; 99private Task SendToAllConnections(string methodName, object?[] args, Func<HubConnectionContext, object?, bool>? include, object? state = null, CancellationToken cancellationToken = default) 105foreach (var connection in _connections) 147private static void SendToGroupConnections(string methodName, object?[] args, ConcurrentDictionary<string, HubConnectionContext> connections, Func<HubConnectionContext, object?, bool>? include, object? state, ref List<Task>? tasks, ref SerializedHubMessage? message, CancellationToken cancellationToken) 187var connection = _connections[connectionId]; 292public override Task OnConnectedAsync(HubConnectionContext connection) 299public override Task OnDisconnectedAsync(HubConnectionContext connection) 338var connection = _connections[connectionId];
DefaultUserIdProvider.cs (2)
10/// This provider gets the user ID from the connection's <see cref="HubConnectionContext.User"/> name identifier claim. 15public virtual string? GetUserId(HubConnectionContext connection)
HubConnectionContext.cs (9)
65/// Initializes a new instance of the <see cref="HubConnectionContext"/> class. 80_logger = loggerFactory.CreateLogger(typeof(HubConnectionContext)); 82_closedRegistration = connectionContext.ConnectionClosed.Register(static (state) => ((HubConnectionContext)state!).Abort(), this); 87_closedRequestedRegistration = lifetimeNotification.ConnectionClosedRequested.Register(static (state) => ((HubConnectionContext)state!).AbortAllowReconnect(), this); 584Features.Get<IConnectionHeartbeatFeature>()?.OnHeartbeat(state => ((HubConnectionContext)state).KeepAliveTick(), this); 701Features.Get<IConnectionHeartbeatFeature>()?.OnHeartbeat(state => ((HubConnectionContext)state).CheckClientTimeout(), this); 729var connection = (HubConnectionContext)state!; 744static async Task InnerAbortConnection(HubConnectionContext connection)
HubConnectionContextOptions.cs (1)
7/// Options used to configure <see cref="HubConnectionContext"/>.
HubConnectionHandler.cs (5)
134var connectionContext = new HubConnectionContext(connection, contextOptions, _loggerFactory) 161private async Task RunHubAsync(HubConnectionContext connection) 200private async Task HubOnDisconnectedAsync(HubConnectionContext connection, Exception? exception) 239private async Task SendCloseAsync(HubConnectionContext connection, Exception? exception, bool allowReconnect) 263private async Task DispatchMessagesAsync(HubConnectionContext connection)
HubConnectionStore.cs (13)
10/// Stores <see cref="HubConnectionContext"/>s by ID. 17private readonly ConcurrentDictionary<string, HubConnectionContext> _connections = 18new ConcurrentDictionary<string, HubConnectionContext>(StringComparer.Ordinal); 21/// Get the <see cref="HubConnectionContext"/> by connection ID. 25public HubConnectionContext? this[string connectionId] 29_connections.TryGetValue(connectionId, out var connection); 40/// Add a <see cref="HubConnectionContext"/> to the store. 43public void Add(HubConnectionContext connection) 49/// Removes a <see cref="HubConnectionContext"/> from the store. 52public void Remove(HubConnectionContext connection) 69public readonly struct Enumerator : IEnumerator<HubConnectionContext> 71private readonly IEnumerator<KeyValuePair<string, HubConnectionContext>> _enumerator; 85public HubConnectionContext Current => _enumerator.Current.Value;
HubLifetimeManager.cs (2)
20public abstract Task OnConnectedAsync(HubConnectionContext connection); 28public abstract Task OnDisconnectedAsync(HubConnectionContext connection);
Internal\DefaultHubCallerContext.cs (2)
14private readonly HubConnectionContext _connection; 16public DefaultHubCallerContext(HubConnectionContext connection)
Internal\DefaultHubDispatcher.cs (17)
83public override async Task OnConnectedAsync(HubConnectionContext connection) 119public override async Task OnDisconnectedAsync(HubConnectionContext connection, Exception? exception) 154public override Task DispatchMessageAsync(HubConnectionContext connection, HubMessage hubMessage) 245private Task ProcessInvocationBindingFailure(HubConnectionContext connection, InvocationBindingFailureMessage bindingFailureMessage) 254private Task ProcessStreamBindingFailure(HubConnectionContext connection, StreamBindingFailureMessage bindingFailureMessage) 270private Task ProcessStreamItem(HubConnectionContext connection, StreamItemMessage message) 282private Task ProcessInvocation(HubConnectionContext connection, 318private async Task<bool> Invoke(HubMethodDescriptor descriptor, HubConnectionContext connection, 391HubConnectionContext connection, 492private static ValueTask CleanupInvocation(HubConnectionContext connection, HubMethodInvocationMessage hubMessage, IHubActivator<THub>? hubActivator, 511private async Task StreamAsync(string invocationId, HubConnectionContext connection, object?[] arguments, AsyncServiceScope scope, 606private ValueTask<object?> ExecuteHubMethod(ObjectMethodExecutor methodExecutor, THub hub, object?[] arguments, HubConnectionContext connection, IServiceProvider serviceProvider) 648private static async Task SendInvocationError(string? invocationId, HubConnectionContext connection, string errorMessage) 658private void InitializeHub(THub hub, HubConnectionContext connection, bool invokeAllowed = true) 665private static Task<bool> IsHubMethodAuthorized(IServiceProvider provider, HubConnectionContext hubConnectionContext, HubMethodDescriptor descriptor, object?[] hubMethodArguments, Hub hub) 691HubMethodInvocationMessage hubMethodInvocationMessage, HubConnectionContext connection) 719HubConnectionContext connection, AsyncServiceScope scope, ref object?[] arguments, out CancellationTokenSource? cts)
Internal\HubConnectionBinder.cs (2)
11private readonly HubConnectionContext _connection; 14public HubConnectionBinder(HubDispatcher<THub> dispatcher, HubLifetimeManager<THub> lifetimeManager, HubConnectionContext connection)
Internal\HubDispatcher.cs (3)
11public abstract Task OnConnectedAsync(HubConnectionContext connection); 12public abstract Task OnDisconnectedAsync(HubConnectionContext connection, Exception? exception); 13public abstract Task DispatchMessageAsync(HubConnectionContext connection, HubMessage hubMessage);
Internal\HubGroupList.cs (9)
9internal sealed class HubGroupList : IReadOnlyCollection<ConcurrentDictionary<string, HubConnectionContext>> 16public ConcurrentDictionary<string, HubConnectionContext>? this[string groupName] 25public void Add(HubConnectionContext connection, string groupName) 34if (connections.TryRemove(connectionId, out var _) && connections.IsEmpty) 47public IEnumerator<ConcurrentDictionary<string, HubConnectionContext>> GetEnumerator() 57private void CreateOrUpdateGroupWithConnection(string groupName, HubConnectionContext connection) 68HubConnectionContext connection, GroupConnectionList group) 75internal sealed class GroupConnectionList : ConcurrentDictionary<string, HubConnectionContext> 79if (obj is ConcurrentDictionary<string, HubConnectionContext> list)
IUserIdProvider.cs (1)
17string? GetUserId(HubConnectionContext connection);
Microsoft.AspNetCore.SignalR.Microbenchmarks (5)
BroadcastBenchmark.cs (1)
50var hubConnection = new HubConnectionContext(connection, contextOptions, NullLoggerFactory.Instance);
DefaultHubDispatcherBenchmark.cs (1)
20private HubConnectionContext _connectionContext;
DefaultHubLifetimeManagerBenchmark.cs (1)
55var hubConnectionContext = new HubConnectionContext(connectionContext, contextOptions, NullLoggerFactory.Instance);
HubConnectionContextBenchmark.cs (2)
17private HubConnectionContext _hubConnectionContext; 75public string GetUserId(HubConnectionContext connection)
Microsoft.AspNetCore.SignalR.Specification.Tests (46)
HubLifetimeManagerTestBase.cs (18)
40var connection1 = HubConnectionContextUtils.Create(client1.Connection); 41var connection2 = HubConnectionContextUtils.Create(client2.Connection); 71var connection1 = HubConnectionContextUtils.Create(client1.Connection); 72var connection2 = HubConnectionContextUtils.Create(client2.Connection); 101var connection1 = HubConnectionContextUtils.Create(client1.Connection); 102var connection2 = HubConnectionContextUtils.Create(client2.Connection); 131var connection1 = HubConnectionContextUtils.Create(client1.Connection); 132var connection2 = HubConnectionContextUtils.Create(client2.Connection); 161var connection = HubConnectionContextUtils.Create(client.Connection); 185var connection1 = HubConnectionContextUtils.Create(client1.Connection); 212var connection1 = HubConnectionContextUtils.Create(client1.Connection); 240var connection1 = HubConnectionContextUtils.Create(client1.Connection); 241var connection2 = HubConnectionContextUtils.Create(client2.Connection); 275var connection1 = HubConnectionContextUtils.Create(client1.Connection); 296var connection1 = HubConnectionContextUtils.Create(client1.Connection); 297var connection2 = HubConnectionContextUtils.Create(client2.Connection); 328var connection1 = HubConnectionContextUtils.Create(client1.Connection); 353var connection1 = HubConnectionContextUtils.Create(client1.Connection);
ScaleoutHubLifetimeManagerTests.cs (27)
52var connection1 = HubConnectionContextUtils.Create(client1.Connection); 53var connection2 = HubConnectionContextUtils.Create(client2.Connection); 79var connection1 = HubConnectionContextUtils.Create(client1.Connection); 80var connection2 = HubConnectionContextUtils.Create(client2.Connection); 109var connection = HubConnectionContextUtils.Create(client.Connection); 133var connection = HubConnectionContextUtils.Create(client.Connection); 157var connection = HubConnectionContextUtils.Create(client.Connection); 183var connection = HubConnectionContextUtils.Create(client.Connection); 204var connection = HubConnectionContextUtils.Create(client.Connection); 225var connection = HubConnectionContextUtils.Create(client.Connection); 249var connection = HubConnectionContextUtils.Create(client.Connection); 276var connection = HubConnectionContextUtils.Create(client.Connection); 303var connection = HubConnectionContextUtils.Create(client.Connection); 334var connection = HubConnectionContextUtils.Create(client.Connection); 388var connection2 = HubConnectionContextUtils.Create(client2.Connection); 420var connection1 = HubConnectionContextUtils.Create(client1.Connection, userIdentifier: "userA"); 421var connection2 = HubConnectionContextUtils.Create(client2.Connection, userIdentifier: "userA"); 422var connection3 = HubConnectionContextUtils.Create(client3.Connection, userIdentifier: "userB"); 448var connection1 = HubConnectionContextUtils.Create(client1.Connection, userIdentifier: "userA"); 449var connection2 = HubConnectionContextUtils.Create(client2.Connection, userIdentifier: "userA"); 450var connection3 = HubConnectionContextUtils.Create(client3.Connection, userIdentifier: "userB"); 480var connection1 = HubConnectionContextUtils.Create(client1.Connection); 511var connection1 = HubConnectionContextUtils.Create(client1.Connection); 542var connection1 = HubConnectionContextUtils.Create(client1.Connection); 564var connection1 = HubConnectionContextUtils.Create(client1.Connection); 593var connection = HubConnectionContextUtils.Create(client.Connection); 643var connection1 = HubConnectionContextUtils.Create(client1.Connection);
src\SignalR\common\testassets\Tests.Utils\HubConnectionContextUtils.cs (1)
17public static HubConnectionContext Create(ConnectionContext connection, IHubProtocol protocol = null, string userIdentifier = null)
Microsoft.AspNetCore.SignalR.StackExchangeRedis (18)
Internal\RedisSubscriptionManager.cs (2)
13public async Task AddSubscriptionAsync(string id, HubConnectionContext connection, Func<string, HubConnectionStore, Task> subscribeMethod) 42public async Task RemoveSubscriptionAsync(string id, HubConnectionContext connection, object state, Func<object, string, Task> unsubscribeMethod)
RedisHubLifetimeManager.cs (16)
91public override async Task OnConnectedAsync(HubConnectionContext connection) 113public override Task OnDisconnectedAsync(HubConnectionContext connection) 173var connection = _connections[connectionId]; 214var connection = _connections[connectionId]; 230var connection = _connections[connectionId]; 302private Task AddGroupAsyncCore(HubConnectionContext connection, string groupName) 321/// This takes <see cref="HubConnectionContext"/> because we want to remove the connection from the 324private async Task RemoveGroupAsyncCore(HubConnectionContext connection, string groupName) 357private Task RemoveUserAsync(HubConnectionContext connection) 385var connection = _connections[connectionId]; 463foreach (var connection in _connections) 489var connection = _connections[groupMessage.ConnectionId]; 528private async Task SubscribeToConnection(HubConnectionContext connection) 583private Task SubscribeToUser(HubConnectionContext connection) 598foreach (var userConnection in subscriptions) 624foreach (var groupConnection in groupConnections)
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (5)
RedisHubLifetimeManagerTests.cs (4)
64var connection1 = HubConnectionContextUtils.Create(client1.Connection); 65var connection2 = HubConnectionContextUtils.Create(client2.Connection); 114var connection = HubConnectionContextUtils.Create(client.Connection); 137var connection = HubConnectionContextUtils.Create(client.Connection);
Startup.cs (1)
41public string GetUserId(HubConnectionContext connection)
Microsoft.AspNetCore.SignalR.Tests (29)
AddSignalRTests.cs (3)
214public string GetUserId(HubConnectionContext connection) 266public override Task OnConnectedAsync(HubConnectionContext connection) 271public override Task OnDisconnectedAsync(HubConnectionContext connection)
ClientProxyTests.cs (2)
227public override Task OnConnectedAsync(HubConnectionContext connection) 232public override Task OnDisconnectedAsync(HubConnectionContext connection)
DefaultHubLifetimeManagerTests.cs (14)
30var connection1 = HubConnectionContextUtils.Create(client1.Connection); 31var connection2 = HubConnectionContextUtils.Create(client2.Connection); 60var connection1 = HubConnectionContextUtils.Create(client1.Connection); 61var connection2 = HubConnectionContextUtils.Create(client2.Connection); 86var connection1 = HubConnectionContextUtils.Create(client1.Connection); 108var connection1 = HubConnectionContextUtils.Create(client1.Connection); 130var connection1 = HubConnectionContextUtils.Create(client1.Connection); 154var connection1 = HubConnectionContextUtils.Create(client1.Connection); 155var connection2 = HubConnectionContextUtils.Create(client2.Connection); 182var connection1 = HubConnectionContextUtils.Create(client1.Connection); 206var connection1 = HubConnectionContextUtils.Create(client1.Connection, userIdentifier: "user"); 207var connection2 = HubConnectionContextUtils.Create(client2.Connection, userIdentifier: "user"); 236var connection1 = HubConnectionContextUtils.Create(client1.Connection, userIdentifier: "user1"); 237var connection2 = HubConnectionContextUtils.Create(client2.Connection, userIdentifier: "user2");
HubConnectionHandlerTests.cs (10)
694.Setup(m => m.OnConnectedAsync(It.IsAny<HubConnectionContext>())) 719mockLifetimeManager.Verify(m => m.OnConnectedAsync(It.IsAny<HubConnectionContext>()), Times.Once); 720mockLifetimeManager.Verify(m => m.OnDisconnectedAsync(It.IsAny<HubConnectionContext>()), Times.Once); 754mockLifetimeManager.Verify(m => m.OnConnectedAsync(It.IsAny<HubConnectionContext>()), Times.Once); 755mockLifetimeManager.Verify(m => m.OnDisconnectedAsync(It.IsAny<HubConnectionContext>()), Times.Once); 787mockLifetimeManager.Verify(m => m.OnConnectedAsync(It.IsAny<HubConnectionContext>()), Times.Once); 788mockLifetimeManager.Verify(m => m.OnDisconnectedAsync(It.IsAny<HubConnectionContext>()), Times.Once); 5404private readonly Func<HubConnectionContext, string> _getUserId; 5406public TestUserIdProvider(Func<HubConnectionContext, string> getUserId) 5411public string GetUserId(HubConnectionContext connection) => _getUserId(connection);
Microsoft.AspNetCore.SignalR.Tests.Utils (1)
HubConnectionContextUtils.cs (1)
17public static HubConnectionContext Create(ConnectionContext connection, IHubProtocol protocol = null, string userIdentifier = null)