diff --git a/samples/ChatSample/PresenceHubLifetimeManager.cs b/samples/ChatSample/PresenceHubLifetimeManager.cs index 991f46a168..841eeaa907 100644 --- a/samples/ChatSample/PresenceHubLifetimeManager.cs +++ b/samples/ChatSample/PresenceHubLifetimeManager.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; -using Microsoft.AspNetCore.Sockets; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.SignalR.Redis; @@ -113,7 +112,7 @@ namespace ChatSample hub.Clients = _hubContext.Clients; hub.Context = new HubCallerContext(connection); - hub.Groups = new GroupManager(this); + hub.Groups = _hubContext.Groups; try { diff --git a/src/Microsoft.AspNetCore.SignalR/HubContext.cs b/src/Microsoft.AspNetCore.SignalR/HubContext.cs index 3464e78417..c527174b6d 100644 --- a/src/Microsoft.AspNetCore.SignalR/HubContext.cs +++ b/src/Microsoft.AspNetCore.SignalR/HubContext.cs @@ -6,17 +6,19 @@ namespace Microsoft.AspNetCore.SignalR public class HubContext : IHubContext, IHubClients where THub : Hub { private readonly HubLifetimeManager _lifetimeManager; - private readonly AllClientProxy _all; public HubContext(HubLifetimeManager lifetimeManager) { _lifetimeManager = lifetimeManager; - _all = new AllClientProxy(_lifetimeManager); + All = new AllClientProxy(_lifetimeManager); + Groups = new GroupManager(lifetimeManager); } public IHubClients Clients => this; - public virtual IClientProxy All => _all; + public virtual IClientProxy All { get; } + + public virtual IGroupManager Groups { get; } public virtual IClientProxy Client(string connectionId) { diff --git a/src/Microsoft.AspNetCore.SignalR/HubEndPoint.cs b/src/Microsoft.AspNetCore.SignalR/HubEndPoint.cs index 0560101270..4ade79b872 100644 --- a/src/Microsoft.AspNetCore.SignalR/HubEndPoint.cs +++ b/src/Microsoft.AspNetCore.SignalR/HubEndPoint.cs @@ -363,7 +363,7 @@ namespace Microsoft.AspNetCore.SignalR { hub.Clients = _hubContext.Clients; hub.Context = new HubCallerContext(connection); - hub.Groups = new GroupManager(_lifetimeManager); + hub.Groups = _hubContext.Groups; } private bool IsChannel(Type type, out Type payloadType) diff --git a/src/Microsoft.AspNetCore.SignalR/IHubContext.cs b/src/Microsoft.AspNetCore.SignalR/IHubContext.cs index 77b1ba181a..88c004aec2 100644 --- a/src/Microsoft.AspNetCore.SignalR/IHubContext.cs +++ b/src/Microsoft.AspNetCore.SignalR/IHubContext.cs @@ -8,8 +8,10 @@ using System.Threading.Tasks; namespace Microsoft.AspNetCore.SignalR { - public interface IHubContext where THub: Hub + public interface IHubContext where THub : Hub { IHubClients Clients { get; } + + IGroupManager Groups { get; } } } diff --git a/src/Microsoft.AspNetCore.SignalR/Proxies.cs b/src/Microsoft.AspNetCore.SignalR/Proxies.cs index bf4359cdbd..048ee43ba9 100644 --- a/src/Microsoft.AspNetCore.SignalR/Proxies.cs +++ b/src/Microsoft.AspNetCore.SignalR/Proxies.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Sockets; namespace Microsoft.AspNetCore.SignalR {