views:

394

answers:

3

Right now, I am in prototyping phase. So I am just getting started.

Situation: Server - Will be run tests and publish progress to Client, must be low impact, no webserver, possibly running xp embedded or xp home.

Client - Initiate tests and receive progress report. running xp pro.

The two machines are connected via ethernet. I would like to use .NET remoting to communicate between the two machines, and I would like to use events to update the client with new results from the server, but I've read that events are unreliable in these conditions. How should I do this? Could the Server connect to the client and use remoting to publish the events? Would that work okay?

A: 

By the Server connecting to the client, you are actually inverting the model and causing the server to become the client and vice versa.

You are better off having the client initiate tests, and poll the server for status updates.

Your choice of remoting is not really a big deal (and makes no impact on the opinion I offered), but you may want to investigate its replacement (WCF) instead of spending time on a 'replaced but still supported' technology.

StingyJack
+3  A: 

I once deployed a system wich used remoting, and where the server launched some events to which the client could subscribe to.

In order to make it possible, you have to set the typeFilterLevel to full, and, you also have to create an 'intermediate' object that is known on the client and on the server in order to be able to handle your events.

For instance: This is the class that is known on the server & on the client side.

public abstract class MyDelegateObject : MarshalByRefObject
{
   public void EventHandlerCallback( object sender, EventArgs e )
   {
      EventHandlerCallbackCore(sender, e);
   }

   protected abstract void EventHandlerCallbackCore(object sender, EventArgs e );

   public override object InitializeLifetimeService() { return null; }
}

At the client-side, you create another class which inherits from the above class, and implements the actual logic that must be performed when the event is raised.

public class MyConcreteHandler : MyDelegateObject
{
   protected override EventHandlerCallbackCore(object sender, EventArgs e)
   {
       // do some stuff
   }
}

You simply attach the eventhandler to the event of the remote object like this:

MyConcreteHandler handler = new MyConcreteHandler();
myRemoteObject.MyEventOccured += new EventHandler(handler.EventHandlerCallback);

Offcourse, if you update Winform controls in your EventHandler class, that class should also implement ISynchronizeInvoke.

Frederik Gheysels
+3  A: 

Since you're still in the prototyping stage, you might want to consider using Windows Communication Foundation (WCF) rather than remoting. WCF has built-in support for publish-subscribe scenarios, and already contains all the functionality of .NET remoting and web services (from what I understand).

davogones