SignalR Client - IHubProxy.On <> and Invoke <> interface reception

I am creating a Windows service that will act as a client for an existing site using SignalR.

I have methods IHubProxy.On<> and IHubProxy.Invoke that work when traversing specific classes.

For example, this works:

  hubProxy.On<MigrationRequest>("iSWindowsServiceRequest", request => MigrateData.Invoke(request)); 

And the MigrationRequest looks like this:

 public class MigrationRequest : IISWindowsServiceRequest { public MigrateWhat What { get; set; } public MigrationFor For { get; set; } public Guid EntityFor_Id { get; set; } } 

Now, if I try this:

 hubProxy.On<IISWindowsServiceRequest>("iSWindowsServiceRequest", request => Handshake.HandleRequest(request)); 

My request is never matched.

what I was hoping to achieve was creating single pub-sub methods, not one for each concrete class this service would accept.

Is it possible to pass an interface to On<>() methods?

The same goes for Invoke<>() - if the object I pass contains any properties that have an interface, the call never makes it.

therefore this will not work:

 public class ISWindowsServiceResponse { public IISWindowsServiceRequest OriginalRequest { get; set; } public bool Success { get; set; } public string Message { get; set; } } 

but it will be

 public class ISWindowsServiceResponse { public MigrationRequest OriginalRequest { get; set; } public bool Success { get; set; } public string Message { get; set; } } 
+5
source share
1 answer

Where I work, we spent a lot of time trying to figure out how to get SignalR hubs to serialize interfaces. In the end, we had to retrieve real objects (real classes and structures, not the interface) to send over the wire. Unable to tell SignalR how to serialize the interface.

+1
source

All Articles