Search code examples
signalrsignalr-hubsignalr.clientasp.net-core-signalrsignalr-2

How do I maintain a list of Client methods the Server's Hub can call?


For SignalR 2.1, how do I maintain a list of Client methods the Server's Hub can call?

According to Differences between SignalR and ASP.NET Core SignalR - Hub Proxies, "Hub proxies are no longer automatically generated."

Is there an existing solution to maintain a list of Client methods the Server's Hub can call?

Looking for a solution that defines Client methods to be called by Server Hub before we decide to roll our own with Code Generation.


Solution

  • Looks like Hub and IHubContext take T type parameter for the type of client that you can make an interface for. Can't find any documentation specific to dotnet core other than the source code and comments but look like this is a carry over from .net

    https://blog.scottlogic.com/2014/08/08/signalr-typed.html -> "Calling client hubs - New and Improved"

    public interface IMyHubClient
    {
        void Ping();
    }
     public class MyHub : Hub<IMyHubClient>
    {
        ...
    }