Passing message over network
        Posted  
        
            by Sylvestre Equy
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sylvestre Equy
        
        
        
        Published on 2010-05-13T15:12:44Z
        Indexed on 
            2010/05/13
            15:24 UTC
        
        
        Read the original article
        Hit count: 254
        
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.
© Stack Overflow or respective owner