Reputation: 385
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.
Upvotes: 4
Views: 713
Reputation: 34177
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.
Upvotes: 2