Hello,
I am facing an issue when i try to invoke a method at SignalR Server from SignalR client.
Background:
Hub.Invoke("MethodToBeCalled", MessageType).Wait();
The MessageType is defined as
public class MessageType
{
primitive type prop1;
primitive type prop2;
List<BaseAction> Actions {get;set;}
}
BaseAction is a base class for two derived types; RunningAction and RowingAction.
Issue:
When i pass the CLR object of MessageType to the Hub.Invoke all the type information are lost when they reach the SignalRHub so basically i can't tell apart RunningAction from RowingAction because JSON Serialization just considers them all as BaseAction(BaseType).
Could anyone suggest if there is a way to workaround this problem?
Thanks in advance:)
What I have tried:
I have tried the
Hub.JsonSerializer.TypeNameHandling = TypeNameHandling.All;
at the client before the connection is started. But when i do this it always fails with Server 503.
No change when trying the same at the SignalR(OWIN) server side:
var myHubJsonSetting = new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.All
};
var serializer = JsonSerializer.Create(myHubJsonSetting);
_signalR =
WebApp.Start(
GetStartupOptions(),
builder =>
{
builder.UseCors(CorsOptions.AllowAll);
GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);
builder.MapSignalR(
serviceName,
new HubConfiguration
{
EnableJSONP = false,
EnableDetailedErrors = _detailedErrors,
EnableJavaScriptProxies = true
});
builder.RunSignalR();
});