// 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.Collections.Generic; namespace Microsoft.AspNetCore.SignalR { public class HubContext : IHubContext, IHubClients where THub : Hub where T : class { private readonly HubLifetimeManager _lifetimeManager; public HubContext(HubLifetimeManager lifetimeManager) { _lifetimeManager = lifetimeManager; All = TypedClientBuilder.Build(new AllClientProxy(_lifetimeManager)); Groups = new GroupManager(lifetimeManager); } public IHubClients Clients => this; public virtual T All { get; } public virtual IGroupManager Groups { get; } public T AllExcept(IReadOnlyList excludedIds) { return TypedClientBuilder.Build(new AllClientsExceptProxy(_lifetimeManager, excludedIds)); } public virtual T Client(string connectionId) { return TypedClientBuilder.Build(new SingleClientProxy(_lifetimeManager, connectionId)); } public virtual T Group(string groupName) { return TypedClientBuilder.Build(new GroupProxy(_lifetimeManager, groupName)); } public virtual T User(string userId) { return TypedClientBuilder.Build(new UserProxy(_lifetimeManager, userId)); } } }