I am using SignalR in version 2.1.2. I noticed that for me there are two classes of the public hub, Hub and Hub<T> . The first has an MSDN page, which appears to be outdated, and the second does not have any MSDN page at all. I believe that the MSDN documentation is not updated with the latest version of SignalR from Nuget (which I use), because sources decompiled with ReSharper show both classes inheriting from the HubBase base class. The MSDN IHub Page Hierarchy section shows that the Hub class inherits from Object and implements the IHub and IDisposable , however decompiled sources expose the aforementioned HubBase base class by implementing the IHub interface, which turns IDisposable tools into.
The difference between the universal and universal variant of classes is that the non-generic one Clients property returns IHubCallerConnectionContext<dynamic> , while the general variant returns the typed IHubCallerConnectionContext<T> .
I would like my clients to type, so when I call client methods from a hub, I will have the correct Intellisense support and strongly typed arguments. However, I'm struggling with letting the hub know that my client model method is actually being called in the browser.
This is my TestModel class:
public sealed class TestModel { public String Name { get; set; } public void Notify() {} public void NotifyComplex(TestModel model) {} }
With a non-shared hub, I simply called .Notify() or .Notify(new TestModel() { Name = "sth" }) in dynamic ly bound this.Context.Clients.Client(…) or this.Context.Caller , but with by a common class when I call these empty methods in a similar way the browser is not notified at all.
How do you use the general hub class in the way it should be used?
Tomáš Hübelbauer
source share