예제 #1
0
        private SipContext ConvertToContext(byte[] bytes, IPEndPoint from,  IPEndPoint to)
        {
            Datagram datagram = new Datagram(bytes, from , to);
            var message = new SipParser2(_messageFactory, _headerFactory).Parse(datagram);

            return CreateSipContext(message, datagram);
        }
예제 #2
0
        private object ProcessIncomingDatagram(object argument)
        {
            var datagram = argument as Datagram;

            _logger.Trace("Processing incoming datagram ...");

            _logger.Trace("Parsing datagram ...");
            SipMessage message;

            try
            {
                message = new SipParser2(_messageFactory, _headerFactory).Parse(datagram);
                _logger.Trace("Datagram parsed.");
            }
            catch (Exception err)
            {
                _logger.ErrorException(string.Format("Failed parsing datagram. Exception: {0}", err.Message), err);
                UnhandledException(this, new ExceptionEventArgs()
                {
                    Exception = err
                });
                return(0);
            }

            var c = CreateSipContext(message, datagram);

            try
            {
                NewContextReceived(this, new SipContextReceivedEventArgs()
                {
                    Context = c
                });
            }
            catch (Exception err)
            {
                _logger.ErrorException(string.Format("Unhandled exception occured. Exception: {0}", err.Message), err);
                UnhandledException(this, new ExceptionEventArgs()
                {
                    Exception = err
                });
            }

            return(1);
        }
예제 #3
0
 protected override void Given()
 {
     _parser = new SipParser2(new SipMessageFactory(), new SipHeaderFactory());
 }
예제 #4
0
        private object ProcessIncomingDatagram(object argument)
        {
            var datagram = argument as Datagram;

            _logger.Trace("Processing incoming datagram ...");

            _logger.Trace("Parsing datagram ...");
            SipMessage message;
            try
            {
                message = new SipParser2(_messageFactory, _headerFactory).Parse(datagram);
                _logger.Trace("Datagram parsed.");
            }
            catch (Exception err)
            {
                _logger.ErrorException(string.Format("Failed parsing datagram. Exception: {0}", err.Message), err);
                UnhandledException(this, new ExceptionEventArgs() { Exception = err });
                return 0;
            }

            var c = CreateSipContext(message, datagram);
            
            try
            {
                NewContextReceived(this, new SipContextReceivedEventArgs() { Context = c });
            }
            catch (Exception err)
            {
                _logger.ErrorException(string.Format("Unhandled exception occured. Exception: {0}", err.Message), err);
                UnhandledException(this, new ExceptionEventArgs() {Exception = err});
            }

            return 1;
        }