diff --git a/src/Microsoft.AspNetCore.SignalR.Core/DynamicHubClients.cs b/src/Microsoft.AspNetCore.SignalR.Core/DynamicHubClients.cs index 3f75f1d90e..6b4f4db8c0 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/DynamicHubClients.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/DynamicHubClients.cs @@ -1,6 +1,8 @@ // 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 DynamicHubClients @@ -13,6 +15,7 @@ namespace Microsoft.AspNetCore.SignalR } public dynamic All => new DynamicClientProxy(_clients.All); + public dynamic AllExcept(IReadOnlyList excludedIds) => new DynamicClientProxy(_clients.AllExcept(excludedIds)); public dynamic User(string userId) => new DynamicClientProxy(_clients.User(userId)); public dynamic Group(string group) => new DynamicClientProxy(_clients.Group(group)); public dynamic Client(string connectionId) => new DynamicClientProxy(_clients.Client(connectionId)); diff --git a/src/Microsoft.AspNetCore.SignalR.Core/IHubClients.cs b/src/Microsoft.AspNetCore.SignalR.Core/IHubClients.cs index 823a9db9d2..47a3cc05f3 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/IHubClients.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/IHubClients.cs @@ -5,16 +5,5 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.SignalR { - public interface IHubClients - { - IClientProxy All { get; } - - IClientProxy AllExcept(IReadOnlyList excludedIds); - - IClientProxy Client(string connectionId); - - IClientProxy Group(string groupName); - - IClientProxy User(string userId); - } + public interface IHubClients : IHubClients { } } diff --git a/src/Microsoft.AspNetCore.SignalR.Core/IHubClients`T.cs b/src/Microsoft.AspNetCore.SignalR.Core/IHubClients`T.cs index 637e0da43d..92c75ddc3d 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/IHubClients`T.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/IHubClients`T.cs @@ -11,6 +11,8 @@ namespace Microsoft.AspNetCore.SignalR { T All { get; } + T AllExcept(IReadOnlyList excludedIds); + T Client(string connectionId); T Group(string groupName); diff --git a/src/Microsoft.AspNetCore.SignalR.Core/TypedHubClients.cs b/src/Microsoft.AspNetCore.SignalR.Core/TypedHubClients.cs index db835ff951..6677d6b240 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/TypedHubClients.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/TypedHubClients.cs @@ -1,6 +1,8 @@ // 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 { internal class TypedHubClients : IHubClients @@ -14,6 +16,8 @@ namespace Microsoft.AspNetCore.SignalR public T All => TypedClientBuilder.Build(hubClients.All); + public T AllExcept(IReadOnlyList excludedIds) => TypedClientBuilder.Build(hubClients.AllExcept(excludedIds)); + public T Client(string connectionId) { return TypedClientBuilder.Build(hubClients.Client(connectionId)); diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs index fce843d018..5a6602c69c 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs @@ -512,12 +512,13 @@ namespace Microsoft.AspNetCore.SignalR.Tests } } - [Fact] - public async Task SendToAllExcept() + [Theory] + [MemberData(nameof(HubTypes))] + public async Task SendToAllExcept(Type hubType) { var serviceProvider = CreateServiceProvider(); - var endPoint = serviceProvider.GetService>(); + dynamic endPoint = serviceProvider.GetService(GetEndPointType(hubType)); using (var firstClient = new TestClient()) using (var secondClient = new TestClient()) @@ -945,6 +946,11 @@ namespace Microsoft.AspNetCore.SignalR.Tests { return Clients.All.Broadcast(message); } + + public Task SendToAllExcept(string message, IReadOnlyList excludedIds) + { + return Clients.AllExcept(excludedIds).Send(message); + } } public interface Test @@ -995,6 +1001,11 @@ namespace Microsoft.AspNetCore.SignalR.Tests { return Clients.All.Broadcast(message); } + + public Task SendToAllExcept(string message, IReadOnlyList excludedIds) + { + return Clients.AllExcept(excludedIds).Send(message); + } } public class StreamingHub : TestHub