Parses and builds messages

The message factory takes care of building messages from all end points.

Since both message and packet protocols are used, the factory hands out contexts to all end points. The context keeps a state to be able to parse partial messages properly.

Each end point need to hand the context back to the message factory when the client disconnects (or a message have been parsed).

 public MessageFactoryContext(MessageFactory msgFactory, HeaderFactory factory, SipParser parser)
 {
     _msgFactory = msgFactory;
     _factory = factory;
     _parser = parser;
     parser.HeaderParsed += OnHeader;
     parser.MessageComplete += OnMessageComplete;
     parser.RequestLineParsed += OnRequestLine;
     parser.ResponseLineParsed += OnResponseLine;
 }
        public MessageFactoryTest()
        {
            LogFactory.Assign(new ConsoleLogFactory(null));

            _headerFactory = new HeaderFactory();
            _headerFactory.AddDefaultParsers();
            _factory = new MessageFactory(_headerFactory);
            _factory.RequestReceived += OnRequest;
            _factory.ResponseReceived += OnResponse;
        }
Beispiel #3
0
        public TcpTransportTest()
        {
            LogFactory.Assign(new ConsoleLogFactory(null));

            var headerFactory = new HeaderFactory();
            headerFactory.AddDefaultParsers();
            _messageFactory = new MessageFactory(headerFactory);
            _messageFactory.RequestReceived += OnRequest;
            _messageFactory.ResponseReceived += OnResponse;
            var pool = new ObjectPool<byte[]>(CreateBuffer);
            _transport = new TcpTransport(new IPEndPoint(IPAddress.Any, 1324), _messageFactory)
                             {BufferPool = _bufferPool};
            _transport.Start();
            _transport.UnhandledException += OnUnhandledException;
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UdpTransport"/> class.
 /// </summary>
 /// <param name="listeningPoint">End point to accept new connections on.</param>
 /// <param name="parsers">The parsers.</param>
 public UdpTransport(IPEndPoint listeningPoint, MessageFactory parsers)
 {
     _listeningPoint = listeningPoint;
     _parsers = parsers;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TcpTransport"/> class.
 /// </summary>
 /// <param name="endPoint">End point to accept new connections on.</param>
 /// <param name="factory">Message factory.</param>
 public TcpTransport(IPEndPoint endPoint, MessageFactory factory)
 {
     _listeningPoint = endPoint;
     _factory = factory;
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransportLayer"/> class.
 /// </summary>
 public TransportLayer(MessageFactory messageFactory)
 {
     _messageFactory = messageFactory;
     _messageFactory.RequestReceived += OnRequest;
     _messageFactory.ResponseReceived += OnResponse;
 }
Beispiel #7
0
 public SipStack()
 {
     var hf = new HeaderFactory();
     hf.AddDefaultParsers();
     _messageFactory = new MessageFactory(hf);
     _transportLayer = new TransportLayer(MessageFactory);
     _transportLayer.RequestReceived += OnRequest;
     _transportLayer.ResponseReceived += OnResponse;
     _transactionManager = new TransactionManager(_transportLayer);
     _dialogManager = new DialogManager(this);
     _authenticator = new Authenticator();
 }