-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and servers
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
When using a strongly typed SignalR hub, HubMethodNameAttribute in the client type is used, but the same doesn't happen if the server methods are declared in an implemented interface.
Given:
public interface INotifications
{
public const string ReceiveMessageMethodName = "ReceiveMessage";
[HubMethodName(ReceiveMessageMethodName)]
public Task ReceiveMessageAsync(string user, string message);
}
public interface IMethods
{
public const string SendMessageMethodName = "SendMessage";
[HubMethodName(SendMessageMethodName)]
public Task SendMessageAsync(string user, string message);
}In this hub:
public class NotificationsHub : Hub<INotifications>, IMethods
{
public async Task SendMessageAsync(string user, string message)
{
await Clients.All.ReceiveMessageAsync(user, message);
}
}The client method is ReceiveMessage and the server method is SendMessageAsync.
Describe the solution you'd like
The server method should be SendMessage.
Additional context
By changing this code to:
var methodName =
methodInfo.GetCustomAttribute<HubMethodNameAttribute>(inherit: true)?.Name ??
methodInfo.Name;it should work.
This is a breaking change, though,
Metadata
Metadata
Assignees
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and servers