API review changes for Microsoft.AspNetCore.SignalR (#2033)

This commit is contained in:
James Newton-King 2018-04-16 15:54:42 +12:00 committed by GitHub
parent 6eac7049ba
commit b3a9011698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 84 additions and 86 deletions

View File

@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
var hubConnection = new HubConnectionContext(connection, Timeout.InfiniteTimeSpan, NullLoggerFactory.Instance); var hubConnection = new HubConnectionContext(connection, Timeout.InfiniteTimeSpan, NullLoggerFactory.Instance);
hubConnection.Protocol = protocol; hubConnection.Protocol = protocol;
_hubLifetimeManager.OnConnectedAsync(hubConnection).GetAwaiter().GetResult(); _hubLifetimeManager.OnConnectedAsync(hubConnection).GetAwaiter().GetResult();
_hubLifetimeManager.AddGroupAsync(connection.ConnectionId, TestGroupName).GetAwaiter().GetResult(); _hubLifetimeManager.AddToGroupAsync(connection.ConnectionId, TestGroupName).GetAwaiter().GetResult();
_ = ConsumeAsync(connection.Application); _ = ConsumeAsync(connection.Application);
} }

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.SignalR.Internal;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.SignalR.Microbenchmarks namespace Microsoft.AspNetCore.SignalR.Microbenchmarks

View File

@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
hubConnectionContext.Protocol = jsonHubProtocol; hubConnectionContext.Protocol = jsonHubProtocol;
_hubLifetimeManager.OnConnectedAsync(hubConnectionContext).GetAwaiter().GetResult(); _hubLifetimeManager.OnConnectedAsync(hubConnectionContext).GetAwaiter().GetResult();
_hubLifetimeManager.AddGroupAsync(connectionId, groupName); _hubLifetimeManager.AddToGroupAsync(connectionId, groupName);
} }
} }

View File

@ -49,11 +49,11 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
_manager1 = new RedisHubLifetimeManager<TestHub>(logger, options, resolver); _manager1 = new RedisHubLifetimeManager<TestHub>(logger, options, resolver);
_manager2 = new RedisHubLifetimeManager<TestHub>(logger, options, resolver); _manager2 = new RedisHubLifetimeManager<TestHub>(logger, options, resolver);
async Task ConnectClient(TestClient client, IHubProtocol protocol, string userId, string group) async Task ConnectClient(TestClient client, IHubProtocol protocol, string userId, string groupName)
{ {
await _manager2.OnConnectedAsync(HubConnectionContextUtils.Create(client.Connection, protocol, userId)); await _manager2.OnConnectedAsync(HubConnectionContextUtils.Create(client.Connection, protocol, userId));
await _manager2.AddGroupAsync(client.Connection.ConnectionId, "Everyone"); await _manager2.AddToGroupAsync(client.Connection.ConnectionId, "Everyone");
await _manager2.AddGroupAsync(client.Connection.ConnectionId, group); await _manager2.AddToGroupAsync(client.Connection.ConnectionId, groupName);
} }
// Connect clients // Connect clients

View File

@ -173,14 +173,14 @@ namespace ChatSample
return _wrappedHubLifetimeManager.SendUserAsync(userId, methodName, args); return _wrappedHubLifetimeManager.SendUserAsync(userId, methodName, args);
} }
public override Task AddGroupAsync(string connectionId, string groupName) public override Task AddToGroupAsync(string connectionId, string groupName)
{ {
return _wrappedHubLifetimeManager.AddGroupAsync(connectionId, groupName); return _wrappedHubLifetimeManager.AddToGroupAsync(connectionId, groupName);
} }
public override Task RemoveGroupAsync(string connectionId, string groupName) public override Task RemoveFromGroupAsync(string connectionId, string groupName)
{ {
return _wrappedHubLifetimeManager.RemoveGroupAsync(connectionId, groupName); return _wrappedHubLifetimeManager.RemoveFromGroupAsync(connectionId, groupName);
} }
public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList<string> excludedIds) public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList<string> excludedIds)

View File

@ -46,7 +46,7 @@ namespace SignalRSamples.Hubs
public async Task JoinGroup(string groupName) public async Task JoinGroup(string groupName)
{ {
await Groups.AddAsync(Context.ConnectionId, groupName); await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
await Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId} joined {groupName}"); await Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId} joined {groupName}");
} }
@ -55,7 +55,7 @@ namespace SignalRSamples.Hubs
{ {
await Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId} left {groupName}"); await Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId} left {groupName}");
await Groups.RemoveAsync(Context.ConnectionId, groupName); await Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
} }
public Task Echo(string message) public Task Echo(string message)

View File

@ -41,7 +41,7 @@ namespace SignalRSamples.Hubs
public async Task JoinGroup(string groupName) public async Task JoinGroup(string groupName)
{ {
await Groups.AddAsync(Context.ConnectionId, groupName); await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
await Clients.Group(groupName).Send($"{Context.ConnectionId} joined {groupName}"); await Clients.Group(groupName).Send($"{Context.ConnectionId} joined {groupName}");
} }
@ -50,7 +50,7 @@ namespace SignalRSamples.Hubs
{ {
await Clients.Group(groupName).Send($"{Context.ConnectionId} left {groupName}"); await Clients.Group(groupName).Send($"{Context.ConnectionId} left {groupName}");
await Groups.RemoveAsync(Context.ConnectionId, groupName); await Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
} }
public Task Echo(string message) public Task Echo(string message)

View File

@ -41,7 +41,7 @@ namespace SignalRSamples.Hubs
public async Task JoinGroup(string groupName) public async Task JoinGroup(string groupName)
{ {
await Groups.AddAsync(Context.ConnectionId, groupName); await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
await Clients.Group(groupName).Send($"{Context.ConnectionId} joined {groupName}"); await Clients.Group(groupName).Send($"{Context.ConnectionId} joined {groupName}");
} }
@ -50,7 +50,7 @@ namespace SignalRSamples.Hubs
{ {
await Clients.Group(groupName).Send($"{Context.ConnectionId} left {groupName}"); await Clients.Group(groupName).Send($"{Context.ConnectionId} left {groupName}");
await Groups.RemoveAsync(Context.ConnectionId, groupName); await Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
} }
public Task Echo(string message) public Task Echo(string message)

View File

@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.SignalR namespace Microsoft.AspNetCore.SignalR
{ {
public static class IClientProxyExtensions public static class ClientProxyExtensions
{ {
/// <summary> /// <summary>
/// Invokes a method on the connection(s) represented by the <see cref="IClientProxy"/> instance. /// Invokes a method on the connection(s) represented by the <see cref="IClientProxy"/> instance.

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.SignalR
_logger = logger; _logger = logger;
} }
public override Task AddGroupAsync(string connectionId, string groupName) public override Task AddToGroupAsync(string connectionId, string groupName)
{ {
if (connectionId == null) if (connectionId == null)
{ {
@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.SignalR
return Task.CompletedTask; return Task.CompletedTask;
} }
public override Task RemoveGroupAsync(string connectionId, string groupName) public override Task RemoveFromGroupAsync(string connectionId, string groupName)
{ {
if (connectionId == null) if (connectionId == null)
{ {

View File

@ -52,7 +52,8 @@ namespace Microsoft.AspNetCore.SignalR
public virtual IDictionary<object, object> Items => _connectionContext.Items; public virtual IDictionary<object, object> Items => _connectionContext.Items;
public virtual PipeReader Input => _connectionContext.Transport.Input; // Used by HubConnectionHandler
internal PipeReader Input => _connectionContext.Transport.Input;
public string UserIdentifier { get; set; } public string UserIdentifier { get; set; }

View File

@ -30,9 +30,9 @@ namespace Microsoft.AspNetCore.SignalR
public abstract Task SendUsersAsync(IReadOnlyList<string> userIds, string methodName, object[] args); public abstract Task SendUsersAsync(IReadOnlyList<string> userIds, string methodName, object[] args);
public abstract Task AddGroupAsync(string connectionId, string groupName); public abstract Task AddToGroupAsync(string connectionId, string groupName);
public abstract Task RemoveGroupAsync(string connectionId, string groupName); public abstract Task RemoveFromGroupAsync(string connectionId, string groupName);
} }
} }

View File

@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.SignalR
{ {
public interface IGroupManager public interface IGroupManager
{ {
Task AddAsync(string connectionId, string groupName); Task AddToGroupAsync(string connectionId, string groupName);
Task RemoveAsync(string connectionId, string groupName); Task RemoveFromGroupAsync(string connectionId, string groupName);
} }
} }

View File

@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.SignalR
{ {
T All { get; } T All { get; }
T AllExcept(IReadOnlyList<string> excludedIds); T AllExcept(IReadOnlyList<string> excludedConnectionIds);
T Client(string connectionId); T Client(string connectionId);
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.SignalR
T Groups(IReadOnlyList<string> groupNames); T Groups(IReadOnlyList<string> groupNames);
T GroupExcept(string groupName, IReadOnlyList<string> excludeIds); T GroupExcept(string groupName, IReadOnlyList<string> excludedConnectionIds);
T User(string userId); T User(string userId);

View File

@ -5,7 +5,7 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.SignalR namespace Microsoft.AspNetCore.SignalR.Internal
{ {
public class DefaultHubActivator<THub> : IHubActivator<THub> where THub: Hub public class DefaultHubActivator<THub> : IHubActivator<THub> where THub: Hub
{ {
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.SignalR
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
} }
public THub Create() public virtual THub Create()
{ {
Debug.Assert(!_created.HasValue, "hub activators must not be reused."); Debug.Assert(!_created.HasValue, "hub activators must not be reused.");
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.SignalR
return hub; return hub;
} }
public void Release(THub hub) public virtual void Release(THub hub)
{ {
if (hub == null) if (hub == null)
{ {

View File

@ -8,7 +8,7 @@ using System.Security.Claims;
using System.Threading; using System.Threading;
using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.SignalR namespace Microsoft.AspNetCore.SignalR.Internal
{ {
public class DefaultHubCallerContext : HubCallerContext public class DefaultHubCallerContext : HubCallerContext
{ {

View File

@ -24,9 +24,9 @@ namespace Microsoft.AspNetCore.SignalR.Internal
public IClientProxy All => _hubClients.All; public IClientProxy All => _hubClients.All;
public IClientProxy AllExcept(IReadOnlyList<string> excludedIds) public IClientProxy AllExcept(IReadOnlyList<string> excludedConnectionIds)
{ {
return _hubClients.AllExcept(excludedIds); return _hubClients.AllExcept(excludedConnectionIds);
} }
public IClientProxy Client(string connectionId) public IClientProxy Client(string connectionId)
@ -49,9 +49,9 @@ namespace Microsoft.AspNetCore.SignalR.Internal
return _hubClients.GroupExcept(groupName, _currentConnectionId); return _hubClients.GroupExcept(groupName, _currentConnectionId);
} }
public IClientProxy GroupExcept(string groupName, IReadOnlyList<string> excludeIds) public IClientProxy GroupExcept(string groupName, IReadOnlyList<string> excludedConnectionIds)
{ {
return _hubClients.GroupExcept(groupName, excludeIds); return _hubClients.GroupExcept(groupName, excludedConnectionIds);
} }
public IClientProxy User(string userId) public IClientProxy User(string userId)

View File

@ -17,9 +17,9 @@ namespace Microsoft.AspNetCore.SignalR.Internal
public IClientProxy All { get; } public IClientProxy All { get; }
public IClientProxy AllExcept(IReadOnlyList<string> excludedIds) public IClientProxy AllExcept(IReadOnlyList<string> excludedConnectionIds)
{ {
return new AllClientsExceptProxy<THub>(_lifetimeManager, excludedIds); return new AllClientsExceptProxy<THub>(_lifetimeManager, excludedConnectionIds);
} }
public IClientProxy Client(string connectionId) public IClientProxy Client(string connectionId)
@ -32,9 +32,9 @@ namespace Microsoft.AspNetCore.SignalR.Internal
return new GroupProxy<THub>(_lifetimeManager, groupName); return new GroupProxy<THub>(_lifetimeManager, groupName);
} }
public IClientProxy GroupExcept(string groupName, IReadOnlyList<string> excludeIds) public IClientProxy GroupExcept(string groupName, IReadOnlyList<string> excludedConnectionIds)
{ {
return new GroupExceptProxy<THub>(_lifetimeManager, groupName, excludeIds); return new GroupExceptProxy<THub>(_lifetimeManager, groupName, excludedConnectionIds);
} }
public IClientProxy Clients(IReadOnlyList<string> connectionIds) public IClientProxy Clients(IReadOnlyList<string> connectionIds)

View File

@ -17,9 +17,9 @@ namespace Microsoft.AspNetCore.SignalR.Internal
public T All { get; } public T All { get; }
public T AllExcept(IReadOnlyList<string> excludedIds) public T AllExcept(IReadOnlyList<string> excludedConnectionIds)
{ {
return TypedClientBuilder<T>.Build(new AllClientsExceptProxy<THub>(_lifetimeManager, excludedIds)); return TypedClientBuilder<T>.Build(new AllClientsExceptProxy<THub>(_lifetimeManager, excludedConnectionIds));
} }
public virtual T Client(string connectionId) public virtual T Client(string connectionId)
@ -37,9 +37,9 @@ namespace Microsoft.AspNetCore.SignalR.Internal
return TypedClientBuilder<T>.Build(new GroupProxy<THub>(_lifetimeManager, groupName)); return TypedClientBuilder<T>.Build(new GroupProxy<THub>(_lifetimeManager, groupName));
} }
public T GroupExcept(string groupName, IReadOnlyList<string> excludeIds) public T GroupExcept(string groupName, IReadOnlyList<string> excludedConnectionIds)
{ {
return TypedClientBuilder<T>.Build(new GroupExceptProxy<THub>(_lifetimeManager, groupName, excludeIds)); return TypedClientBuilder<T>.Build(new GroupExceptProxy<THub>(_lifetimeManager, groupName, excludedConnectionIds));
} }
public T Groups(IReadOnlyList<string> groupNames) public T Groups(IReadOnlyList<string> groupNames)

View File

@ -6,7 +6,7 @@ using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
namespace Microsoft.AspNetCore.SignalR namespace Microsoft.AspNetCore.SignalR.Internal
{ {
public class HubConnectionStore public class HubConnectionStore
{ {

View File

@ -168,14 +168,14 @@ namespace Microsoft.AspNetCore.SignalR.Internal
_lifetimeManager = lifetimeManager; _lifetimeManager = lifetimeManager;
} }
public Task AddAsync(string connectionId, string groupName) public Task AddToGroupAsync(string connectionId, string groupName)
{ {
return _lifetimeManager.AddGroupAsync(connectionId, groupName); return _lifetimeManager.AddToGroupAsync(connectionId, groupName);
} }
public Task RemoveAsync(string connectionId, string groupName) public Task RemoveFromGroupAsync(string connectionId, string groupName)
{ {
return _lifetimeManager.RemoveGroupAsync(connectionId, groupName); return _lifetimeManager.RemoveFromGroupAsync(connectionId, groupName);
} }
} }
} }

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.SignalR
public T Others => TypedClientBuilder<T>.Build(_hubClients.Others); public T Others => TypedClientBuilder<T>.Build(_hubClients.Others);
public T AllExcept(IReadOnlyList<string> excludedIds) => TypedClientBuilder<T>.Build(_hubClients.AllExcept(excludedIds)); public T AllExcept(IReadOnlyList<string> excludedConnectionIds) => TypedClientBuilder<T>.Build(_hubClients.AllExcept(excludedConnectionIds));
public T Client(string connectionId) public T Client(string connectionId)
{ {
@ -32,9 +32,9 @@ namespace Microsoft.AspNetCore.SignalR
return TypedClientBuilder<T>.Build(_hubClients.Group(groupName)); return TypedClientBuilder<T>.Build(_hubClients.Group(groupName));
} }
public T GroupExcept(string groupName, IReadOnlyList<string> excludeIds) public T GroupExcept(string groupName, IReadOnlyList<string> excludedConnectionIds)
{ {
return TypedClientBuilder<T>.Build(_hubClients.GroupExcept(groupName, excludeIds)); return TypedClientBuilder<T>.Build(_hubClients.GroupExcept(groupName, excludedConnectionIds));
} }
public T Clients(IReadOnlyList<string> connectionIds) public T Clients(IReadOnlyList<string> connectionIds)

View File

@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis
if (groupNames != null) if (groupNames != null)
{ {
// Copy the groups to an array here because they get removed from this collection // Copy the groups to an array here because they get removed from this collection
// in RemoveGroupAsync // in RemoveFromGroupAsync
foreach (var group in groupNames.ToArray()) foreach (var group in groupNames.ToArray())
{ {
// Use RemoveGroupAsyncCore because the connection is local and we don't want to // Use RemoveGroupAsyncCore because the connection is local and we don't want to
@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis
return PublishAsync(_channels.User(userId), message); return PublishAsync(_channels.User(userId), message);
} }
public override async Task AddGroupAsync(string connectionId, string groupName) public override async Task AddToGroupAsync(string connectionId, string groupName)
{ {
if (connectionId == null) if (connectionId == null)
{ {
@ -188,7 +188,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis
await SendGroupActionAndWaitForAck(connectionId, groupName, GroupAction.Add); await SendGroupActionAndWaitForAck(connectionId, groupName, GroupAction.Add);
} }
public override async Task RemoveGroupAsync(string connectionId, string groupName) public override async Task RemoveFromGroupAsync(string connectionId, string groupName)
{ {
if (connectionId == null) if (connectionId == null)
{ {

View File

@ -18,11 +18,6 @@ namespace Microsoft.AspNetCore.SignalR
_routes = routes; _routes = routes;
} }
public void MapHub<THub>(string path) where THub : Hub
{
MapHub<THub>(new PathString(path), configureOptions: null);
}
public void MapHub<THub>(PathString path) where THub : Hub public void MapHub<THub>(PathString path) where THub : Hub
{ {
MapHub<THub>(path, configureOptions: null); MapHub<THub>(path, configureOptions: null);

View File

@ -13,14 +13,14 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
return message; return message;
} }
public Task EchoGroup(string group, string message) public Task EchoGroup(string groupName, string message)
{ {
return Clients.Group(group).SendAsync("Echo", message); return Clients.Group(groupName).SendAsync("Echo", message);
} }
public Task AddSelfToGroup(string group) public Task AddSelfToGroup(string groupName)
{ {
return Groups.AddAsync(Context.ConnectionId, group); return Groups.AddToGroupAsync(Context.ConnectionId, groupName);
} }
} }
} }

View File

@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager.OnConnectedAsync(connection1).OrTimeout(); await manager.OnConnectedAsync(connection1).OrTimeout();
await manager.OnConnectedAsync(connection2).OrTimeout(); await manager.OnConnectedAsync(connection2).OrTimeout();
await manager.AddGroupAsync(connection1.ConnectionId, "gunit").OrTimeout(); await manager.AddToGroupAsync(connection1.ConnectionId, "gunit").OrTimeout();
await manager.SendGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout(); await manager.SendGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout();
@ -134,8 +134,8 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager.OnConnectedAsync(connection1).OrTimeout(); await manager.OnConnectedAsync(connection1).OrTimeout();
await manager.OnConnectedAsync(connection2).OrTimeout(); await manager.OnConnectedAsync(connection2).OrTimeout();
await manager.AddGroupAsync(connection1.ConnectionId, "gunit").OrTimeout(); await manager.AddToGroupAsync(connection1.ConnectionId, "gunit").OrTimeout();
await manager.AddGroupAsync(connection2.ConnectionId, "gunit").OrTimeout(); await manager.AddToGroupAsync(connection2.ConnectionId, "gunit").OrTimeout();
var excludedIds = new List<string> { client2.Connection.ConnectionId }; var excludedIds = new List<string> { client2.Connection.ConnectionId };
await manager.SendGroupExceptAsync("gunit", "Hello", new object[] { "World" }, excludedIds).OrTimeout(); await manager.SendGroupExceptAsync("gunit", "Hello", new object[] { "World" }, excludedIds).OrTimeout();
@ -257,7 +257,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager1.OnConnectedAsync(connection).OrTimeout(); await manager1.OnConnectedAsync(connection).OrTimeout();
await manager1.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager1.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout();
@ -278,7 +278,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager.OnConnectedAsync(connection).OrTimeout(); await manager.OnConnectedAsync(connection).OrTimeout();
await manager.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager.OnDisconnectedAsync(connection).OrTimeout(); await manager.OnDisconnectedAsync(connection).OrTimeout();
@ -301,7 +301,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager.OnConnectedAsync(connection).OrTimeout(); await manager.OnConnectedAsync(connection).OrTimeout();
await manager.RemoveGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager.RemoveFromGroupAsync(connection.ConnectionId, "name").OrTimeout();
} }
} }
@ -319,7 +319,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager1.OnConnectedAsync(connection).OrTimeout(); await manager1.OnConnectedAsync(connection).OrTimeout();
await manager2.RemoveGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager2.RemoveFromGroupAsync(connection.ConnectionId, "name").OrTimeout();
} }
} }
@ -337,7 +337,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager1.OnConnectedAsync(connection).OrTimeout(); await manager1.OnConnectedAsync(connection).OrTimeout();
await manager2.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager2.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout();
@ -358,8 +358,8 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager.OnConnectedAsync(connection).OrTimeout(); await manager.OnConnectedAsync(connection).OrTimeout();
await manager.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await manager.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout();
@ -382,8 +382,8 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager1.OnConnectedAsync(connection).OrTimeout(); await manager1.OnConnectedAsync(connection).OrTimeout();
await manager1.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager1.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager2.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager2.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout();
@ -406,13 +406,13 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
await manager1.OnConnectedAsync(connection).OrTimeout(); await manager1.OnConnectedAsync(connection).OrTimeout();
await manager1.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager1.AddToGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout();
await AssertMessageAsync(client); await AssertMessageAsync(client);
await manager2.RemoveGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager2.RemoveFromGroupAsync(connection.ConnectionId, "name").OrTimeout();
await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout();
@ -484,9 +484,9 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
var connection2 = HubConnectionContextUtils.Create(client2.Connection); var connection2 = HubConnectionContextUtils.Create(client2.Connection);
await manager.OnConnectedAsync(connection1).OrTimeout(); await manager.OnConnectedAsync(connection1).OrTimeout();
await manager.AddGroupAsync(connection1.ConnectionId, "group"); await manager.AddToGroupAsync(connection1.ConnectionId, "group");
await manager.OnConnectedAsync(connection2).OrTimeout(); await manager.OnConnectedAsync(connection2).OrTimeout();
await manager.AddGroupAsync(connection2.ConnectionId, "group"); await manager.AddToGroupAsync(connection2.ConnectionId, "group");
await manager.SendGroupAsync("group", "Hello", new object[] { "World" }).OrTimeout(); await manager.SendGroupAsync("group", "Hello", new object[] { "World" }).OrTimeout();
// connection1 will throw when receiving a group message, we are making sure other connections // connection1 will throw when receiving a group message, we are making sure other connections

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.AspNetCore.SignalR.Internal;
using Moq; using Moq;
using Moq.Protected; using Moq.Protected;
using Xunit; using Xunit;

View File

@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
await manager.OnConnectedAsync(connection1).OrTimeout(); await manager.OnConnectedAsync(connection1).OrTimeout();
await manager.OnConnectedAsync(connection2).OrTimeout(); await manager.OnConnectedAsync(connection2).OrTimeout();
await manager.AddGroupAsync(connection1.ConnectionId, "gunit").OrTimeout(); await manager.AddToGroupAsync(connection1.ConnectionId, "gunit").OrTimeout();
await manager.SendGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout(); await manager.SendGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout();
@ -101,8 +101,8 @@ namespace Microsoft.AspNetCore.SignalR.Tests
await manager.OnConnectedAsync(connection1).OrTimeout(); await manager.OnConnectedAsync(connection1).OrTimeout();
await manager.OnConnectedAsync(connection2).OrTimeout(); await manager.OnConnectedAsync(connection2).OrTimeout();
await manager.AddGroupAsync(connection1.ConnectionId, "gunit").OrTimeout(); await manager.AddToGroupAsync(connection1.ConnectionId, "gunit").OrTimeout();
await manager.AddGroupAsync(connection2.ConnectionId, "gunit").OrTimeout(); await manager.AddToGroupAsync(connection2.ConnectionId, "gunit").OrTimeout();
await manager.SendGroupExceptAsync("gunit", "Hello", new object[] { "World" }, new []{ connection2.ConnectionId }).OrTimeout(); await manager.SendGroupExceptAsync("gunit", "Hello", new object[] { "World" }, new []{ connection2.ConnectionId }).OrTimeout();
@ -145,14 +145,14 @@ namespace Microsoft.AspNetCore.SignalR.Tests
public async Task AddGroupOnNonExistentConnectionNoops() public async Task AddGroupOnNonExistentConnectionNoops()
{ {
var manager = new DefaultHubLifetimeManager<MyHub>(new Logger<DefaultHubLifetimeManager<MyHub>>(NullLoggerFactory.Instance)); var manager = new DefaultHubLifetimeManager<MyHub>(new Logger<DefaultHubLifetimeManager<MyHub>>(NullLoggerFactory.Instance));
await manager.AddGroupAsync("NotARealConnectionId", "MyGroup").OrTimeout(); await manager.AddToGroupAsync("NotARealConnectionId", "MyGroup").OrTimeout();
} }
[Fact] [Fact]
public async Task RemoveGroupOnNonExistentConnectionNoops() public async Task RemoveGroupOnNonExistentConnectionNoops()
{ {
var manager = new DefaultHubLifetimeManager<MyHub>(new Logger<DefaultHubLifetimeManager<MyHub>>(NullLoggerFactory.Instance)); var manager = new DefaultHubLifetimeManager<MyHub>(new Logger<DefaultHubLifetimeManager<MyHub>>(NullLoggerFactory.Instance));
await manager.RemoveGroupAsync("NotARealConnectionId", "MyGroup").OrTimeout(); await manager.RemoveFromGroupAsync("NotARealConnectionId", "MyGroup").OrTimeout();
} }
private class MyHub : Hub private class MyHub : Hub

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
{ {
public Task GroupRemoveMethod(string groupName) public Task GroupRemoveMethod(string groupName)
{ {
return Groups.RemoveAsync(Context.ConnectionId, groupName); return Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
} }
public Task ClientSendMethod(string userId, string message) public Task ClientSendMethod(string userId, string message)
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
public Task GroupAddMethod(string groupName) public Task GroupAddMethod(string groupName)
{ {
return Groups.AddAsync(Context.ConnectionId, groupName); return Groups.AddToGroupAsync(Context.ConnectionId, groupName);
} }
public Task GroupSendMethod(string groupName, string message) public Task GroupSendMethod(string groupName, string message)
@ -204,7 +204,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
public Task GroupAddMethod(string groupName) public Task GroupAddMethod(string groupName)
{ {
return Groups.AddAsync(Context.ConnectionId, groupName); return Groups.AddToGroupAsync(Context.ConnectionId, groupName);
} }
public Task GroupSendMethod(string groupName, string message) public Task GroupSendMethod(string groupName, string message)
@ -290,7 +290,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
public Task GroupAddMethod(string groupName) public Task GroupAddMethod(string groupName)
{ {
return Groups.AddAsync(Context.ConnectionId, groupName); return Groups.AddToGroupAsync(Context.ConnectionId, groupName);
} }
public Task GroupSendMethod(string groupName, string message) public Task GroupSendMethod(string groupName, string message)