Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SignalR] Allocate HubCallerClients once per connection #31661

Merged
merged 1 commit into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[SignalR] Allocate HubCallerClients once per connection
  • Loading branch information
BrennanConroy committed Apr 10, 2021
commit 765ce4d4b3506d715ae89b371f0d34a3c48a574d
1 change: 1 addition & 0 deletions src/SignalR/server/Core/src/HubConnectionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ internal StreamTracker StreamTracker
}

internal HubCallerContext HubCallerContext { get; }
internal HubCallerClients HubCallerClients { get; set; } = null!;

internal Exception? CloseException { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public DefaultHubDispatcher(IServiceScopeFactory serviceScopeFactory, IHubContex
public override async Task OnConnectedAsync(HubConnectionContext connection)
{
var scope = _serviceScopeFactory.CreateScope();
connection.HubCallerClients = new HubCallerClients(_hubContext.Clients, connection.ConnectionId);

try
{
Expand Down Expand Up @@ -558,7 +559,7 @@ private async Task SendInvocationError(string? invocationId,

private void InitializeHub(THub hub, HubConnectionContext connection)
{
hub.Clients = new HubCallerClients(_hubContext.Clients, connection.ConnectionId);
hub.Clients = connection.HubCallerClients;
hub.Context = connection.HubCallerContext;
hub.Groups = _hubContext.Groups;
}
Expand Down