json.net - Serializing/deserializing derived objects in SignalR -


i using signalr 1.1 .net clients. have single method in hub accepts object of basemessage class , broadcasts clients:

public void sendmessage(basemessage message) {     clients.all.broadcastmessage(message); } 

clients pass derived messages method:

_hub.invoke("sendmessage", new errormessage("some error")).wait(); 

the client has single message handler:

_hub.on<basemessage>("broadcastmessage", onmessagereceived); 

i've specified typenamehandling.all serializer settings @ application startup:

var settings = new jsonserializersettings { typenamehandling = typenamehandling.all}; var serializer = new jsonnetserializer(settings); globalhost.dependencyresolver.register(typeof(ijsonserializer), () => serializer); 

but when client sends derived message, server receives base message.

how should configure serializer able receive derived messages?

note: can serialization/deserialization manually , pass strings server, causes double serialization.

signalr not supporting scenario require json payload contain information derived type , assembly. see sample. adding type information in payload not play browsers. suggest create individual hub methods handle each of derived types.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -