From d38764a8f0a9cc189e84c28113a5a7aa5b5535d7 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Fri, 19 Jan 2018 11:32:50 -0800 Subject: [PATCH] Rename InvokeAsync to SendAsync on the server (#1312) --- .../BroadcastBenchmark.cs | 4 +- .../TestHub.cs | 4 +- samples/ChatSample/Hubs/Chat.cs | 8 +-- .../ChatSample/PresenceHubLifetimeManager.cs | 36 ++++++------ samples/JwtSample/Broadcaster.cs | 2 +- samples/SocketsSample/Hubs/Chat.cs | 20 +++---- .../DefaultHubLifetimeManager.cs | 30 +++++----- .../DynamicClientProxy.cs | 2 +- .../HubLifetimeManager.cs | 18 +++--- .../IClientProxy.cs | 3 +- .../IClientProxyExtensions.cs | 55 +++++++++++-------- .../Proxies.cs | 36 ++++++------ .../TypedClientBuilder.cs | 8 +-- .../RedisHubLifetimeManager.cs | 18 +++--- .../Hubs.cs | 4 +- .../EchoHub.cs | 2 +- .../RedisHubLifetimeManagerTests.cs | 42 +++++++------- .../DefaultHubLifetimeManagerTests.cs | 12 ++-- .../HubEndpointTestUtils/Hubs.cs | 32 +++++------ .../HubEndpointTests.cs | 2 +- 20 files changed, 175 insertions(+), 163 deletions(-) diff --git a/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs b/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs index e9e6734987..11213fa5c4 100644 --- a/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs @@ -40,9 +40,9 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks } [Benchmark] - public Task InvokeAsyncAll() + public Task SendAsyncAll() { - return _hubContext.Clients.All.InvokeAsync("Method"); + return _hubContext.Clients.All.SendAsync("Method"); } } } diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/TestHub.cs b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/TestHub.cs index 44ed712c93..8ff27a36b1 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/TestHub.cs +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/TestHub.cs @@ -29,12 +29,12 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server public Task InvokeWithString(string message) { - return Clients.Client(Context.Connection.ConnectionId).InvokeAsync("Message", message); + return Clients.Client(Context.Connection.ConnectionId).SendAsync("Message", message); } public Task SendCustomObject(CustomObject customObject) { - return Clients.Client(Context.ConnectionId).InvokeAsync("CustomObject", customObject); + return Clients.Client(Context.ConnectionId).SendAsync("CustomObject", customObject); } public IObservable Stream() diff --git a/samples/ChatSample/Hubs/Chat.cs b/samples/ChatSample/Hubs/Chat.cs index 9eecbe51b6..75c1440992 100644 --- a/samples/ChatSample/Hubs/Chat.cs +++ b/samples/ChatSample/Hubs/Chat.cs @@ -17,23 +17,23 @@ namespace ChatSample.Hubs public override async Task OnConnectedAsync() { - await Clients.Client(Context.ConnectionId).InvokeAsync("SetUsersOnline", await GetUsersOnline()); + await Clients.Client(Context.ConnectionId).SendAsync("SetUsersOnline", await GetUsersOnline()); await base.OnConnectedAsync(); } public override Task OnUsersJoined(UserDetails[] users) { - return Clients.Client(Context.ConnectionId).InvokeAsync("UsersJoined", new[] { users }); + return Clients.Client(Context.ConnectionId).SendAsync("UsersJoined", new[] { users }); } public override Task OnUsersLeft(UserDetails[] users) { - return Clients.Client(Context.ConnectionId).InvokeAsync("UsersLeft", new[] { users }); + return Clients.Client(Context.ConnectionId).SendAsync("UsersLeft", new[] { users }); } public async Task Send(string message) { - await Clients.All.InvokeAsync("Send", Context.User.Identity.Name, message); + await Clients.All.SendAsync("Send", Context.User.Identity.Name, message); } } } diff --git a/samples/ChatSample/PresenceHubLifetimeManager.cs b/samples/ChatSample/PresenceHubLifetimeManager.cs index db881b2d0c..587b97de3e 100644 --- a/samples/ChatSample/PresenceHubLifetimeManager.cs +++ b/samples/ChatSample/PresenceHubLifetimeManager.cs @@ -137,39 +137,39 @@ namespace ChatSample _userTracker.UsersLeft -= OnUsersLeft; } - public override Task InvokeAllAsync(string methodName, object[] args) + public override Task SendAllAsync(string methodName, object[] args) { - return _wrappedHubLifetimeManager.InvokeAllAsync(methodName, args); + return _wrappedHubLifetimeManager.SendAllAsync(methodName, args); } - public override Task InvokeAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds) + public override Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds) { - return _wrappedHubLifetimeManager.InvokeAllExceptAsync(methodName, args, excludedIds); + return _wrappedHubLifetimeManager.SendAllExceptAsync(methodName, args, excludedIds); } - public override Task InvokeConnectionAsync(string connectionId, string methodName, object[] args) + public override Task SendConnectionAsync(string connectionId, string methodName, object[] args) { - return _wrappedHubLifetimeManager.InvokeConnectionAsync(connectionId, methodName, args); + return _wrappedHubLifetimeManager.SendConnectionAsync(connectionId, methodName, args); } - public override Task InvokeConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args) + public override Task SendConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args) { - return _wrappedHubLifetimeManager.InvokeConnectionsAsync(connectionIds, methodName, args); + return _wrappedHubLifetimeManager.SendConnectionsAsync(connectionIds, methodName, args); } - public override Task InvokeGroupAsync(string groupName, string methodName, object[] args) + public override Task SendGroupAsync(string groupName, string methodName, object[] args) { - return _wrappedHubLifetimeManager.InvokeGroupAsync(groupName, methodName, args); + return _wrappedHubLifetimeManager.SendGroupAsync(groupName, methodName, args); } - public override Task InvokeGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args) + public override Task SendGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args) { - return _wrappedHubLifetimeManager.InvokeGroupsAsync(groupNames, methodName, args); + return _wrappedHubLifetimeManager.SendGroupsAsync(groupNames, methodName, args); } - public override Task InvokeUserAsync(string userId, string methodName, object[] args) + public override Task SendUserAsync(string userId, string methodName, object[] args) { - return _wrappedHubLifetimeManager.InvokeUserAsync(userId, methodName, args); + return _wrappedHubLifetimeManager.SendUserAsync(userId, methodName, args); } public override Task AddGroupAsync(string connectionId, string groupName) @@ -182,14 +182,14 @@ namespace ChatSample return _wrappedHubLifetimeManager.RemoveGroupAsync(connectionId, groupName); } - public override Task InvokeGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds) + public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds) { - return _wrappedHubLifetimeManager.InvokeGroupExceptAsync(groupName, methodName, args, excludedIds); + return _wrappedHubLifetimeManager.SendGroupExceptAsync(groupName, methodName, args, excludedIds); } - public override Task InvokeUsersAsync(IReadOnlyList userIds, string methodName, object[] args) + public override Task SendUsersAsync(IReadOnlyList userIds, string methodName, object[] args) { - return _wrappedHubLifetimeManager.InvokeUsersAsync(userIds, methodName, args); + return _wrappedHubLifetimeManager.SendUsersAsync(userIds, methodName, args); } } } diff --git a/samples/JwtSample/Broadcaster.cs b/samples/JwtSample/Broadcaster.cs index 42408af174..1ae408d81c 100644 --- a/samples/JwtSample/Broadcaster.cs +++ b/samples/JwtSample/Broadcaster.cs @@ -12,6 +12,6 @@ namespace JwtSample public class Broadcaster : Hub { public Task Broadcast(string sender, string message) => - Clients.All.InvokeAsync("Message", sender, message); + Clients.All.SendAsync("Message", sender, message); } } diff --git a/samples/SocketsSample/Hubs/Chat.cs b/samples/SocketsSample/Hubs/Chat.cs index 54f0daa5a3..8804bbe197 100644 --- a/samples/SocketsSample/Hubs/Chat.cs +++ b/samples/SocketsSample/Hubs/Chat.cs @@ -12,56 +12,56 @@ namespace SocketsSample.Hubs { public override async Task OnConnectedAsync() { - await Clients.All.InvokeAsync("Send", $"{Context.ConnectionId} joined"); + await Clients.All.SendAsync("Send", $"{Context.ConnectionId} joined"); } public override async Task OnDisconnectedAsync(Exception ex) { - await Clients.Others.InvokeAsync("Send", $"{Context.ConnectionId} left"); + await Clients.Others.SendAsync("Send", $"{Context.ConnectionId} left"); } public Task Send(string message) { - return Clients.All.InvokeAsync("Send", $"{Context.ConnectionId}: {message}"); + return Clients.All.SendAsync("Send", $"{Context.ConnectionId}: {message}"); } public Task SendToOthers(string message) { - return Clients.Others.InvokeAsync("Send", $"{Context.ConnectionId}: {message}"); + return Clients.Others.SendAsync("Send", $"{Context.ConnectionId}: {message}"); } public Task SendToConnection(string connectionId, string message) { - return Clients.Client(connectionId).InvokeAsync("Send", $"Private message from {Context.ConnectionId}: {message}"); + return Clients.Client(connectionId).SendAsync("Send", $"Private message from {Context.ConnectionId}: {message}"); } public Task SendToGroup(string groupName, string message) { - return Clients.Group(groupName).InvokeAsync("Send", $"{Context.ConnectionId}@{groupName}: {message}"); + return Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId}@{groupName}: {message}"); } public Task SendToOthersInGroup(string groupName, string message) { - return Clients.OthersInGroup(groupName).InvokeAsync("Send", $"{Context.ConnectionId}@{groupName}: {message}"); + return Clients.OthersInGroup(groupName).SendAsync("Send", $"{Context.ConnectionId}@{groupName}: {message}"); } public async Task JoinGroup(string groupName) { await Groups.AddAsync(Context.ConnectionId, groupName); - await Clients.Group(groupName).InvokeAsync("Send", $"{Context.ConnectionId} joined {groupName}"); + await Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId} joined {groupName}"); } public async Task LeaveGroup(string groupName) { - await Clients.Group(groupName).InvokeAsync("Send", $"{Context.ConnectionId} left {groupName}"); + await Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId} left {groupName}"); await Groups.RemoveAsync(Context.ConnectionId, groupName); } public Task Echo(string message) { - return Clients.Caller.InvokeAsync("Send", $"{Context.ConnectionId}: {message}"); + return Clients.Caller.SendAsync("Send", $"{Context.ConnectionId}: {message}"); } } } diff --git a/src/Microsoft.AspNetCore.SignalR.Core/DefaultHubLifetimeManager.cs b/src/Microsoft.AspNetCore.SignalR.Core/DefaultHubLifetimeManager.cs index f924aee91f..2611ce7263 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/DefaultHubLifetimeManager.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/DefaultHubLifetimeManager.cs @@ -60,12 +60,12 @@ namespace Microsoft.AspNetCore.SignalR return Task.CompletedTask; } - public override Task InvokeAllAsync(string methodName, object[] args) + public override Task SendAllAsync(string methodName, object[] args) { - return InvokeAllWhere(methodName, args, c => true); + return SendAllWhere(methodName, args, c => true); } - private Task InvokeAllWhere(string methodName, object[] args, Func include) + private Task SendAllWhere(string methodName, object[] args, Func include) { var count = _connections.Count; if (count == 0) @@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.SignalR return Task.WhenAll(tasks); } - public override Task InvokeConnectionAsync(string connectionId, string methodName, object[] args) + public override Task SendConnectionAsync(string connectionId, string methodName, object[] args) { if (connectionId == null) { @@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.SignalR return connection.WriteAsync(message); } - public override Task InvokeGroupAsync(string groupName, string methodName, object[] args) + public override Task SendGroupAsync(string groupName, string methodName, object[] args) { if (groupName == null) { @@ -127,7 +127,7 @@ namespace Microsoft.AspNetCore.SignalR return Task.CompletedTask; } - public override Task InvokeGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args) + public override Task SendGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args) { // Each task represents the list of tasks for each of the writes within a group var tasks = new List(); @@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.SignalR return Task.WhenAll(tasks); } - public override Task InvokeGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds) + public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds) { if (groupName == null) { @@ -174,9 +174,9 @@ namespace Microsoft.AspNetCore.SignalR return new InvocationMessage(target: methodName, argumentBindingException: null, arguments: args); } - public override Task InvokeUserAsync(string userId, string methodName, object[] args) + public override Task SendUserAsync(string userId, string methodName, object[] args) { - return InvokeAllWhere(methodName, args, connection => + return SendAllWhere(methodName, args, connection => string.Equals(connection.UserIdentifier, userId, StringComparison.Ordinal)); } @@ -193,25 +193,25 @@ namespace Microsoft.AspNetCore.SignalR return Task.CompletedTask; } - public override Task InvokeAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds) + public override Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds) { - return InvokeAllWhere(methodName, args, connection => + return SendAllWhere(methodName, args, connection => { return !excludedIds.Contains(connection.ConnectionId); }); } - public override Task InvokeConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args) + public override Task SendConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args) { - return InvokeAllWhere(methodName, args, connection => + return SendAllWhere(methodName, args, connection => { return connectionIds.Contains(connection.ConnectionId); }); } - public override Task InvokeUsersAsync(IReadOnlyList userIds, string methodName, object[] args) + public override Task SendUsersAsync(IReadOnlyList userIds, string methodName, object[] args) { - return InvokeAllWhere(methodName, args, connection => + return SendAllWhere(methodName, args, connection => { return userIds.Contains(connection.UserIdentifier); }); diff --git a/src/Microsoft.AspNetCore.SignalR.Core/DynamicClientProxy.cs b/src/Microsoft.AspNetCore.SignalR.Core/DynamicClientProxy.cs index a99e04d772..3a1d07e4bf 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/DynamicClientProxy.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/DynamicClientProxy.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.SignalR public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { - result = _clientProxy.InvokeAsync(binder.Name, args); + result = _clientProxy.SendAsync(binder.Name, args); return true; } } diff --git a/src/Microsoft.AspNetCore.SignalR.Core/HubLifetimeManager.cs b/src/Microsoft.AspNetCore.SignalR.Core/HubLifetimeManager.cs index 79e83e5eb1..f76074f392 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/HubLifetimeManager.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/HubLifetimeManager.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.SignalR public abstract Task OnDisconnectedAsync(HubConnectionContext connection); - public abstract Task InvokeAllAsync(string methodName, object[] args); + public abstract Task SendAllAsync(string methodName, object[] args); - public abstract Task InvokeAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds); + public abstract Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds); - public abstract Task InvokeConnectionAsync(string connectionId, string methodName, object[] args); + public abstract Task SendConnectionAsync(string connectionId, string methodName, object[] args); - public abstract Task InvokeConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args); + public abstract Task SendConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args); - public abstract Task InvokeGroupAsync(string groupName, string methodName, object[] args); + public abstract Task SendGroupAsync(string groupName, string methodName, object[] args); - public abstract Task InvokeGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args); + public abstract Task SendGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args); - public abstract Task InvokeGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds); + public abstract Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds); - public abstract Task InvokeUserAsync(string userId, string methodName, object[] args); + public abstract Task SendUserAsync(string userId, string methodName, object[] args); - public abstract Task InvokeUsersAsync(IReadOnlyList userIds, string methodName, object[] args); + public abstract Task SendUsersAsync(IReadOnlyList userIds, string methodName, object[] args); public abstract Task AddGroupAsync(string connectionId, string groupName); diff --git a/src/Microsoft.AspNetCore.SignalR.Core/IClientProxy.cs b/src/Microsoft.AspNetCore.SignalR.Core/IClientProxy.cs index 666d46a035..c3d6535ee9 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/IClientProxy.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/IClientProxy.cs @@ -9,10 +9,11 @@ namespace Microsoft.AspNetCore.SignalR { /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// name of the method to invoke /// argumetns to pass to the client /// A task that represents when the data has been sent to the client. - Task InvokeAsync(string method, object[] args); + Task SendAsync(string method, object[] args); } } diff --git a/src/Microsoft.AspNetCore.SignalR.Core/IClientProxyExtensions.cs b/src/Microsoft.AspNetCore.SignalR.Core/IClientProxyExtensions.cs index 1d4fff5ab0..acd37c5fe3 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/IClientProxyExtensions.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/IClientProxyExtensions.cs @@ -9,42 +9,46 @@ namespace Microsoft.AspNetCore.SignalR { /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method) + public static Task SendAsync(this IClientProxy clientProxy, string method) { - return clientProxy.InvokeAsync(method, Array.Empty()); + return clientProxy.SendAsync(method, Array.Empty()); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke /// The first argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1) { - return clientProxy.InvokeAsync(method, new object[] { arg1 }); + return clientProxy.SendAsync(method, new object[] { arg1 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke /// The first argument /// The second argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -52,13 +56,14 @@ namespace Microsoft.AspNetCore.SignalR /// The second argument /// The third argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -67,13 +72,14 @@ namespace Microsoft.AspNetCore.SignalR /// The third argument /// The fourth argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3, arg4 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3, arg4 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -83,13 +89,14 @@ namespace Microsoft.AspNetCore.SignalR /// The fourth argument /// The fifth argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -100,13 +107,14 @@ namespace Microsoft.AspNetCore.SignalR /// The fifth argument /// The sixth argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -118,13 +126,14 @@ namespace Microsoft.AspNetCore.SignalR /// The sixth argument /// The seventh argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -137,13 +146,14 @@ namespace Microsoft.AspNetCore.SignalR /// The seventh argument /// The eigth argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -157,13 +167,14 @@ namespace Microsoft.AspNetCore.SignalR /// The eigth argument /// The ninth argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); } /// /// Invokes a method on the connection(s) represented by the instance. + /// Does not wait for a response from the receiver. /// /// The /// name of the method to invoke @@ -178,9 +189,9 @@ namespace Microsoft.AspNetCore.SignalR /// The ninth argument /// The tenth argument /// A task that represents when the data has been sent to the client. - public static Task InvokeAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10) + public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10) { - return clientProxy.InvokeAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); + return clientProxy.SendAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); } } } diff --git a/src/Microsoft.AspNetCore.SignalR.Core/Proxies.cs b/src/Microsoft.AspNetCore.SignalR.Core/Proxies.cs index 30ed179c54..ae7a89902a 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/Proxies.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/Proxies.cs @@ -17,9 +17,9 @@ namespace Microsoft.AspNetCore.SignalR _userId = userId; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeUserAsync(_userId, method, args); + return _lifetimeManager.SendUserAsync(_userId, method, args); } } @@ -34,9 +34,9 @@ namespace Microsoft.AspNetCore.SignalR _userIds = userIds; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeUsersAsync(_userIds, method, args); + return _lifetimeManager.SendUsersAsync(_userIds, method, args); } } @@ -51,9 +51,9 @@ namespace Microsoft.AspNetCore.SignalR _groupName = groupName; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeGroupAsync(_groupName, method, args); + return _lifetimeManager.SendGroupAsync(_groupName, method, args); } } @@ -68,9 +68,9 @@ namespace Microsoft.AspNetCore.SignalR _groupNames = groupNames; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeGroupsAsync(_groupNames, method, args); + return _lifetimeManager.SendGroupsAsync(_groupNames, method, args); } } @@ -87,9 +87,9 @@ namespace Microsoft.AspNetCore.SignalR _excludedIds = excludedIds; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeGroupExceptAsync(_groupName, method, args, _excludedIds); + return _lifetimeManager.SendGroupExceptAsync(_groupName, method, args, _excludedIds); } } @@ -102,9 +102,9 @@ namespace Microsoft.AspNetCore.SignalR _lifetimeManager = lifetimeManager; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeAllAsync(method, args); + return _lifetimeManager.SendAllAsync(method, args); } } @@ -119,9 +119,9 @@ namespace Microsoft.AspNetCore.SignalR _excludedIds = excludedIds; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeAllExceptAsync(method, args, _excludedIds); + return _lifetimeManager.SendAllExceptAsync(method, args, _excludedIds); } } @@ -136,9 +136,9 @@ namespace Microsoft.AspNetCore.SignalR _connectionId = connectionId; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeConnectionAsync(_connectionId, method, args); + return _lifetimeManager.SendConnectionAsync(_connectionId, method, args); } } @@ -153,9 +153,9 @@ namespace Microsoft.AspNetCore.SignalR _connectionIds = connectionIds; } - public Task InvokeAsync(string method, params object[] args) + public Task SendAsync(string method, params object[] args) { - return _lifetimeManager.InvokeConnectionsAsync(_connectionIds, method, args); + return _lifetimeManager.SendConnectionsAsync(_connectionIds, method, args); } } diff --git a/src/Microsoft.AspNetCore.SignalR.Core/TypedClientBuilder.cs b/src/Microsoft.AspNetCore.SignalR.Core/TypedClientBuilder.cs index 594ea6b42a..4ad095284b 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/TypedClientBuilder.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/TypedClientBuilder.cs @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.SignalR var methodBuilder = type.DefineMethod(interfaceMethodInfo.Name, methodAttributes); var invokeMethod = typeof(IClientProxy).GetMethod( - "InvokeAsync", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, + "SendAsync", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(object[]) }, null); methodBuilder.SetReturnType(interfaceMethodInfo.ReturnType); @@ -132,14 +132,14 @@ namespace Microsoft.AspNetCore.SignalR var generator = methodBuilder.GetILGenerator(); - // Declare local variable to store the arguments to IClientProxy.InvokeAsync + // Declare local variable to store the arguments to IClientProxy.SendAsync generator.DeclareLocal(typeof(object[])); // Get IClientProxy generator.Emit(OpCodes.Ldarg_0); generator.Emit(OpCodes.Ldfld, proxyField); - // The first argument to IClientProxy.InvokeAsync is this method's name + // The first argument to IClientProxy.SendAsync is this method's name generator.Emit(OpCodes.Ldstr, interfaceMethodInfo.Name); // Create an new object array to hold all the parameters to this method @@ -157,7 +157,7 @@ namespace Microsoft.AspNetCore.SignalR generator.Emit(OpCodes.Stelem_Ref); } - // Call InvokeAsync + // Call SendAsync generator.Emit(OpCodes.Ldloc_0); generator.Emit(OpCodes.Callvirt, invokeMethod); diff --git a/src/Microsoft.AspNetCore.SignalR.Redis/RedisHubLifetimeManager.cs b/src/Microsoft.AspNetCore.SignalR.Redis/RedisHubLifetimeManager.cs index 49acdb7d1d..28f9da4d1d 100644 --- a/src/Microsoft.AspNetCore.SignalR.Redis/RedisHubLifetimeManager.cs +++ b/src/Microsoft.AspNetCore.SignalR.Redis/RedisHubLifetimeManager.cs @@ -146,20 +146,20 @@ namespace Microsoft.AspNetCore.SignalR.Redis return Task.WhenAll(tasks); } - public override Task InvokeAllAsync(string methodName, object[] args) + public override Task SendAllAsync(string methodName, object[] args) { var message = new RedisInvocationMessage(target: methodName, arguments: args); return PublishAsync(_channelNamePrefix, message); } - public override Task InvokeAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds) + public override Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedIds) { var message = new RedisInvocationMessage(target: methodName, excludedIds: excludedIds, arguments: args); return PublishAsync(_channelNamePrefix + ".AllExcept", message); } - public override Task InvokeConnectionAsync(string connectionId, string methodName, object[] args) + public override Task SendConnectionAsync(string connectionId, string methodName, object[] args) { if (connectionId == null) { @@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis return PublishAsync(_channelNamePrefix + "." + connectionId, message); } - public override Task InvokeGroupAsync(string groupName, string methodName, object[] args) + public override Task SendGroupAsync(string groupName, string methodName, object[] args) { if (groupName == null) { @@ -191,7 +191,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis return PublishAsync(_channelNamePrefix + ".group." + groupName, message); } - public override Task InvokeGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds) + public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedIds) { if (groupName == null) { @@ -203,7 +203,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis return PublishAsync(_channelNamePrefix + ".group." + groupName, message); } - public override Task InvokeUserAsync(string userId, string methodName, object[] args) + public override Task SendUserAsync(string userId, string methodName, object[] args) { var message = new RedisInvocationMessage(methodName, args); @@ -574,7 +574,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis }); } - public override Task InvokeConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args) + public override Task SendConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args) { if (connectionIds == null) { @@ -601,7 +601,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis return Task.WhenAll(publishTasks); } - public override Task InvokeGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args) + public override Task SendGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args) { if (groupNames == null) { @@ -621,7 +621,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis return Task.WhenAll(publishTasks); } - public override Task InvokeUsersAsync(IReadOnlyList userIds, string methodName, object[] args) + public override Task SendUsersAsync(IReadOnlyList userIds, string methodName, object[] args) { if (userIds.Count > 0) { diff --git a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs index c17318a31c..35f291fd0f 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs @@ -26,12 +26,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests public async Task CallEcho(string message) { - await Clients.Client(Context.ConnectionId).InvokeAsync("Echo", message); + await Clients.Client(Context.ConnectionId).SendAsync("Echo", message); } public async Task CallHandlerThatDoesntExist() { - await Clients.Client(Context.ConnectionId).InvokeAsync("NoClientHandler"); + await Clients.Client(Context.ConnectionId).SendAsync("NoClientHandler"); } public IEnumerable GetHeaderValues(string[] headerNames) diff --git a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/EchoHub.cs b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/EchoHub.cs index 71d6f6cd71..2ce692906e 100644 --- a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/EchoHub.cs +++ b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/EchoHub.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests public Task EchoGroup(string group, string message) { - return Clients.Group(group).InvokeAsync("Echo", message); + return Clients.Group(group).SendAsync("Echo", message); } public Task AddSelfToGroup(string group) diff --git a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisHubLifetimeManagerTests.cs b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisHubLifetimeManagerTests.cs index bbe5b4c4ca..d1f4eea6e1 100644 --- a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisHubLifetimeManagerTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisHubLifetimeManagerTests.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.OnConnectedAsync(connection1).OrTimeout(); await manager.OnConnectedAsync(connection2).OrTimeout(); - await manager.InvokeAllAsync("Hello", new object[] { "World" }).OrTimeout(); + await manager.SendAllAsync("Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client1); await AssertMessageAsync(client2); @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.OnDisconnectedAsync(connection2).OrTimeout(); - await manager.InvokeAllAsync("Hello", new object[] { "World" }).OrTimeout(); + await manager.SendAllAsync("Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client1); @@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.AddGroupAsync(connection1.ConnectionId, "gunit").OrTimeout(); - await manager.InvokeGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client1); Assert.Null(client2.TryRead()); @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.AddGroupAsync(connection2.ConnectionId, "gunit").OrTimeout(); var excludedIds = new List{ client2.Connection.ConnectionId }; - await manager.InvokeGroupExceptAsync("gunit", "Hello", new object[] { "World" }, excludedIds).OrTimeout(); + await manager.SendGroupExceptAsync("gunit", "Hello", new object[] { "World" }, excludedIds).OrTimeout(); await AssertMessageAsync(client1); Assert.Null(client2.TryRead()); @@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.OnConnectedAsync(connection).OrTimeout(); - await manager.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); @@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests { Factory = t => new TestConnectionMultiplexer() })); - await manager.InvokeConnectionAsync("NotARealConnectionId", "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendConnectionAsync("NotARealConnectionId", "Hello", new object[] { "World" }).OrTimeout(); } [Fact] @@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager1.OnConnectedAsync(connection1).OrTimeout(); await manager2.OnConnectedAsync(connection2).OrTimeout(); - await manager1.InvokeAllAsync("Hello", new object[] { "World" }).OrTimeout(); + await manager1.SendAllAsync("Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client1); await AssertMessageAsync(client2); @@ -222,7 +222,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager2.OnDisconnectedAsync(connection2).OrTimeout(); - await manager2.InvokeAllAsync("Hello", new object[] { "World" }).OrTimeout(); + await manager2.SendAllAsync("Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client1); @@ -252,7 +252,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager1.OnConnectedAsync(connection).OrTimeout(); - await manager2.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); + await manager2.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client); } @@ -280,7 +280,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager1.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); - await manager2.InvokeGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); + await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client); } @@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.OnDisconnectedAsync(connection).OrTimeout(); - await manager.InvokeGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); Assert.Null(client.TryRead()); @@ -375,7 +375,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager2.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); - await manager2.InvokeGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); + await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); @@ -400,7 +400,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); - await manager.InvokeGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); @@ -431,7 +431,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager1.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); await manager2.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); - await manager2.InvokeGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); + await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); @@ -461,13 +461,13 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager1.AddGroupAsync(connection.ConnectionId, "name").OrTimeout(); - await manager2.InvokeGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); + await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client); await manager2.RemoveGroupAsync(connection.ConnectionId, "name").OrTimeout(); - await manager2.InvokeGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); + await manager2.SendGroupAsync("name", "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); Assert.Null(client.TryRead()); @@ -494,7 +494,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager1.OnConnectedAsync(connection).OrTimeout(); await manager2.OnConnectedAsync(connection).OrTimeout(); - await manager1.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); + await manager1.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); @@ -527,7 +527,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests // This doesn't throw because there is no connection.ConnectionId on this server so it has to publish to redis. // And once that happens there is no way to know if the invocation was successful or not. - await manager1.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); + await manager1.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); } } @@ -549,7 +549,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.OnConnectedAsync(connection).OrTimeout(); - var exception = await Assert.ThrowsAsync(() => manager.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout()); + var exception = await Assert.ThrowsAsync(() => manager.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout()); Assert.Equal("Message", exception.Message); } } @@ -577,13 +577,13 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests await manager.OnConnectedAsync(connection2).OrTimeout(); await manager.AddGroupAsync(connection2.ConnectionId, "group"); - await manager.InvokeGroupAsync("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 // are not affected by another connection throwing await AssertMessageAsync(client2); // Repeat to check that group can still be sent to - await manager.InvokeGroupAsync("group", "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendGroupAsync("group", "Hello", new object[] { "World" }).OrTimeout(); await AssertMessageAsync(client2); } } diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/DefaultHubLifetimeManagerTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/DefaultHubLifetimeManagerTests.cs index 7a765591cc..da0ddcc4c1 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/DefaultHubLifetimeManagerTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/DefaultHubLifetimeManagerTests.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests await manager.OnConnectedAsync(connection1).OrTimeout(); await manager.OnConnectedAsync(connection2).OrTimeout(); - await manager.InvokeAllAsync("Hello", new object[] { "World" }).OrTimeout(); + await manager.SendAllAsync("Hello", new object[] { "World" }).OrTimeout(); await connection1.DisposeAsync().OrTimeout(); await connection2.DisposeAsync().OrTimeout(); @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests await manager.OnDisconnectedAsync(connection2).OrTimeout(); - await manager.InvokeAllAsync("Hello", new object[] { "World" }).OrTimeout(); + await manager.SendAllAsync("Hello", new object[] { "World" }).OrTimeout(); await connection1.DisposeAsync().OrTimeout(); await connection2.DisposeAsync().OrTimeout(); @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests await manager.AddGroupAsync(connection1.ConnectionId, "gunit").OrTimeout(); - await manager.InvokeGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendGroupAsync("gunit", "Hello", new object[] { "World" }).OrTimeout(); await connection1.DisposeAsync().OrTimeout(); await connection2.DisposeAsync().OrTimeout(); @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests await manager.OnConnectedAsync(connection).OrTimeout(); - await manager.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout(); await connection.DisposeAsync().OrTimeout(); @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests await manager.OnConnectedAsync(connection).OrTimeout(); - var exception = await Assert.ThrowsAsync(() => manager.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout()); + var exception = await Assert.ThrowsAsync(() => manager.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" }).OrTimeout()); Assert.Equal("Message", exception.Message); } } @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests public async Task InvokeConnectionAsyncOnNonExistentConnectionNoops() { var manager = new DefaultHubLifetimeManager(); - await manager.InvokeConnectionAsync("NotARealConnectionId", "Hello", new object[] { "World" }).OrTimeout(); + await manager.SendConnectionAsync("NotARealConnectionId", "Hello", new object[] { "World" }).OrTimeout(); } [Fact] diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTestUtils/Hubs.cs b/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTestUtils/Hubs.cs index 0bb86bdbf6..c7c88a05d9 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTestUtils/Hubs.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTestUtils/Hubs.cs @@ -19,22 +19,22 @@ namespace Microsoft.AspNetCore.SignalR.Tests.HubEndpointTestUtils public Task ClientSendMethod(string userId, string message) { - return Clients.User(userId).InvokeAsync("Send", message); + return Clients.User(userId).SendAsync("Send", message); } public Task SendToMultipleUsers(IReadOnlyList userIds, string message) { - return Clients.Users(userIds).InvokeAsync("Send", message); + return Clients.Users(userIds).SendAsync("Send", message); } public Task ConnectionSendMethod(string connectionId, string message) { - return Clients.Client(connectionId).InvokeAsync("Send", message); + return Clients.Client(connectionId).SendAsync("Send", message); } public Task SendToMultipleClients(string message, IReadOnlyList connectionIds) { - return Clients.Clients(connectionIds).InvokeAsync("Send", message); + return Clients.Clients(connectionIds).SendAsync("Send", message); } public Task GroupAddMethod(string groupName) @@ -44,37 +44,37 @@ namespace Microsoft.AspNetCore.SignalR.Tests.HubEndpointTestUtils public Task GroupSendMethod(string groupName, string message) { - return Clients.Group(groupName).InvokeAsync("Send", message); + return Clients.Group(groupName).SendAsync("Send", message); } public Task GroupExceptSendMethod(string groupName, string message, IReadOnlyList excludedIds) { - return Clients.GroupExcept(groupName, excludedIds).InvokeAsync("Send", message); + return Clients.GroupExcept(groupName, excludedIds).SendAsync("Send", message); } public Task SendToMultipleGroups(string message, IReadOnlyList groupNames) { - return Clients.Groups(groupNames).InvokeAsync("Send", message); + return Clients.Groups(groupNames).SendAsync("Send", message); } public Task SendToOthersInGroup(string groupName, string message) { - return Clients.OthersInGroup(groupName).InvokeAsync("Send", message); + return Clients.OthersInGroup(groupName).SendAsync("Send", message); } public Task BroadcastMethod(string message) { - return Clients.All.InvokeAsync("Broadcast", message); + return Clients.All.SendAsync("Broadcast", message); } public Task BroadcastItem() { - return Clients.All.InvokeAsync("Broadcast", new Result { Message = "test", paramName = "param" }); + return Clients.All.SendAsync("Broadcast", new Result { Message = "test", paramName = "param" }); } public Task SendArray() { - return Clients.All.InvokeAsync("Array", new int[] { 1, 2, 3 }); + return Clients.All.SendAsync("Array", new int[] { 1, 2, 3 }); } public Task TaskValueMethod() @@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests.HubEndpointTestUtils public Task SendAnonymousObject() { - return Clients.Client(Context.ConnectionId).InvokeAsync("Send", new { }); + return Clients.Client(Context.ConnectionId).SendAsync("Send", new { }); } public override Task OnDisconnectedAsync(Exception e) @@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests.HubEndpointTestUtils public Task SendToAllExcept(string message, IReadOnlyList excludedIds) { - return Clients.AllExcept(excludedIds).InvokeAsync("Send", message); + return Clients.AllExcept(excludedIds).SendAsync("Send", message); } public bool HasHttpContext() @@ -148,12 +148,12 @@ namespace Microsoft.AspNetCore.SignalR.Tests.HubEndpointTestUtils public Task SendToOthers(string message) { - return Clients.Others.InvokeAsync("Send", message); + return Clients.Others.SendAsync("Send", message); } public Task SendToCaller(string message) { - return Clients.Caller.InvokeAsync("Send", message); + return Clients.Caller.SendAsync("Send", message); } } @@ -563,7 +563,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests.HubEndpointTestUtils { public override async Task OnConnectedAsync() { - await Clients.All.InvokeAsync("Send", $"{Context.ConnectionId} joined"); + await Clients.All.SendAsync("Send", $"{Context.ConnectionId} joined"); await base.OnConnectedAsync(); } } diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs index 2341b33bcf..6d308bd92c 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/HubEndpointTests.cs @@ -294,7 +294,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests { var serviceProvider = HubEndPointTestUtils.CreateServiceProvider(); var context = serviceProvider.GetRequiredService>(); - await context.Clients.All.InvokeAsync("Send", "test"); + await context.Clients.All.SendAsync("Send", "test"); } [Fact]