views:

36

answers:

1

Hi,

I'm currently trying to develop a message-oriented networking framework and I'm a bit stuck on the internal mechanism.

Here are the problematic interfaces :

public interface IMessage
{
}


public class Connection
{
    public void Subscribe<TMessage>(Action<TMessage> messageCallback);
    public void Send<TMessage>(TMessage message);   
}

The Send method does not seem complicated, though the mechanism behind Subscribe seems a bit more painful. Obviously when receiving a message on one end of the connection, I'll have to invoke the appropriate delegate. Do you have any advice on how to read messages and easily detect their types ?

By the way, I'd like to avoid to use MSMQ.

+1  A: 

Sounds like a problem Windows Communication Foundation was created to solve: http://msdn.microsoft.com/en-us/netframework/aa663324.aspx but you've tagged the question .NET 2.0 so that may not be an option for you.

Instead, if you're in control of both the client and server sides, take a look at .NET Remoting: http://msdn.microsoft.com/en-us/library/kwdt6w2k(VS.71).aspx.

Daniel Renshaw
+1 good advice, and [you can use WCF with .NET 2.0](http://en.wikipedia.org/wiki/.NET_Framework#.NET_Framework_3.0). Of course depending on what you do with WCF and how you configure it, it may use MSMQ (though I don't understand why anyone would rule out MSMQ for such a system).
Jeff Sternal
Seems like WCF's channels could be an option. I'll try to see what I can do with them and 2.0
Sylvestre Equy