Question

Let's say I have an Instant Messenger server using SignalR. I want to broadcast a ContactList custom object that contains a collection of User custom objects to all connected clients which may be on a variety of platforms.

How do I package these custom objects on the server side to allow java, objective c and .net clients to map back to copies of these classes on their side? I assume some sort of serialization, but don't want to write a "parser" for every client language that reconstructs every different custom object I may want to use. Do I have any better options?

Was it helpful?

Solution

Exposing your objects in a RESTful manner will allow other languages to consume them. As long as all objects you expose are serializable, it doesn't matter what the calling language is as long as they can themselves do REST requests. WCF / Web API handle this nicely.

OTHER TIPS

If you're using SignalR then the format is JSON.

SignalR is technically tied to JSON right now in its architecture (i.e. IJsonSerializer and IJsonValue) and uses JSON.NET by default for serialization. So as long as your objects can be serialized by JSON.NET and as long as those other platforms support parsing JSON in some way (even if it's simple text parsing) then you should be good to go.

I'd like to add that if you want the JSON that comes in over the wire to be automatically deserialized into objects in the various platforms, you could create a PCL (portable class library) using Xamarin to run C# everywhere. Have a look at http://xamarin.com/csharp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top