views:

32

answers:

3

I have a WPF application, that I want to port to Linux/Mac. The most logic way seems to split the application in two parts: client and server, and use Silverlight for the client UI, and run the server-part (as an invisible console-app) in Mono.

But what's the best way to let those two parts communicate? Silverlight 4 supports COM interop, but I cant use that because it will fail in Moonlight. So I was thinking about socket-connection to localhost, and use JSON or something similar. Or is there a better way which doesn't require me to write dozens of wrappers for all the function contained in the server-dll? Because communication will be between Mono<>Moonlight, maybe i can use something similar as COM interop that is cross-platform?

+1  A: 

You're on the right track.

You should create a web server application and the Silverlight app would communicate with it over http://localhost via REST or SOAP.

Michael S. Scherotter
Yes, but how to create the server-part? Just open a socket and process all the handling of REST/SOAP requests myself, or is there a nicer way?
Joshua
@Drazic: Read some books on web development and Silverlight (and RIA Services). You don't need to open any sockets. You'll understand a lot more when you pick up a book.
Gabriel McAdams
@Gabriel: I think you forget this part: 'to localhost'. The end-users will not have IIS installed, so there is no real webserver involved. Just a loopback connection to 127.0.0.1, to seperate frontend/backend. I do not host the application, it runs locally on the users desktop pc.
Joshua
@Joshua: I haven't tried this myself, but I concur that looking at using a socket connection via localhost is the most promising approach I can think of. Consider using System.Runtime.Serialization on both sides to reduce the amount of coding you have to do.Behind the scenes, WCF is a 'message passing' system that uses Serialization to pass MethodName + Properties to a receiver that then invokes the appropriately named delegate...
Jay
A: 

Joshua - I'm a bit confused (and I don't mean that in a negative way). If the app runs on the users machine then isn't there's no "server" to connect with?

What's the nature of the server-side components? - what do they do? Can't you just run the whole thing from within SilverLight?

SilverLight is providing the runtime host for .Net, in that sense it can contain your whole app - which can still be layered like a "conventional" web-based solution, so you can still have separate assembilies for Business Logic, etc.

Adrian K
@Adrian I cannot use pure Silverlight, because my app needs to open sockets to a restricted port/access filesystem/etc. I know there is no "real" server to connect to, that's why im looking into hosting a WCF service from a console app, or write my own tcp-based protocol for communication.
Joshua
A: 

Hi Joshua, maybe you can consider to use Eneter Messaging Framework.
It allows to implement the communication between Silverlight and standalone application based on Tcp. The low level communication is hiden and the framework is very easy to use.
You can see the following example:
http://eneter.blogspot.com/2010/07/silverlight-interprocess-communicatin.html

Ondrej Uzovic