コード例 #1
0
        protected SipRequest CreateCancelRequest(SipRequest request)
        {
            var hf                = new SipHeaderFactory();
            var mf                = new SipMessageFactory();
            var requestUri        = request.RequestLine.Uri.Clone();
            var callIdheader      = (SipCallIdHeader)request.CallId.Clone();
            var cseqHeader        = new SipHeaderFactory().CreateSCeqHeader(SipMethods.Cancel, request.CSeq.Sequence);
            var fromHeader        = (SipFromHeader)request.From.Clone();
            var toHeader          = (SipToHeader)request.To.Clone();
            var viaHeader         = (SipViaHeader)request.Vias.GetTopMost().Clone();
            var maxForwardsHeader = hf.CreateMaxForwardsHeader();
            var cancelRequest     = mf.CreateRequest(
                requestUri,
                SipMethods.Cancel,
                callIdheader,
                cseqHeader,
                fromHeader,
                toHeader,
                viaHeader,
                maxForwardsHeader);

            foreach (var route in request.Routes)
            {
                cancelRequest.Routes.Add((SipRouteHeader)route.Clone());
            }

            return(cancelRequest);
        }
コード例 #2
0
        public SipInviteServerDialog(
             ISipTransaction transaction, 
             SipDialogTable dialogTable,
             ITimerFactory timerFactory,
             SipHeaderFactory headerFactory,
             SipMessageFactory messageFactory,
             SipAddressFactory addressFactory,
             ISipMessageSender messageSender,
             ISipListener listener,
            IPEndPoint listeningPoint)
            : base(headerFactory, messageFactory, addressFactory, messageSender, listener, listeningPoint, transaction)
        {
            Check.Require(transaction, "transaction");
            Check.Require(dialogTable, "dialogTable");
            Check.Require(timerFactory, "timerFactory");

            _logger = NLog.LogManager.GetCurrentClassLogger();

            _dialogTable = dialogTable;
            _state = DialogState.Null;
            _timerFactory = timerFactory;

            //(only ?) localtag is set on firstresponse
            //localtarget is not defined, because is has no use, (every user agent knows it local address)

            _retransmitOkTimer = _timerFactory.CreateInviteCtxRetransmitTimer(OnOkReTransmit);
            //_endWaitForAckTimer = _timerFactory.CreateInviteCtxTimeOutTimer(OnWaitForAckTimeOut);

            if (_logger.IsInfoEnabled) _logger.Info("ServerDialog[Id={0}] created.", GetId());
        }
コード例 #3
0
        public SipInviteServerDialog(
            ISipTransaction transaction,
            SipDialogTable dialogTable,
            ITimerFactory timerFactory,
            SipHeaderFactory headerFactory,
            SipMessageFactory messageFactory,
            SipAddressFactory addressFactory,
            ISipMessageSender messageSender,
            ISipListener listener,
            IPEndPoint listeningPoint)
            : base(headerFactory, messageFactory, addressFactory, messageSender, listener, listeningPoint, transaction)
        {
            Check.Require(transaction, "transaction");
            Check.Require(dialogTable, "dialogTable");
            Check.Require(timerFactory, "timerFactory");

            _logger = NLog.LogManager.GetCurrentClassLogger();

            _dialogTable  = dialogTable;
            _state        = DialogState.Null;
            _timerFactory = timerFactory;

            //(only ?) localtag is set on firstresponse
            //localtarget is not defined, because is has no use, (every user agent knows it local address)

            _retransmitOkTimer = _timerFactory.CreateInviteCtxRetransmitTimer(OnOkReTransmit);
            //_endWaitForAckTimer = _timerFactory.CreateInviteCtxTimeOutTimer(OnWaitForAckTimeOut);

            if (_logger.IsInfoEnabled)
            {
                _logger.Info("ServerDialog[Id={0}] created.", GetId());
            }
        }
コード例 #4
0
        protected SipAbstractDialog(SipHeaderFactory headerFactory,
                                    SipMessageFactory messageFactory,
                                    SipAddressFactory addressFactory,
                                    ISipMessageSender messageSender,
                                    ISipListener listener,
                                    IPEndPoint listeningPoint,
                                    ISipTransaction transaction)

        {
            Check.Require(headerFactory, "headerFactory");
            Check.Require(messageFactory, "messageFactory");
            Check.Require(addressFactory, "addressFactory");
            Check.Require(messageSender, "messageSender");
            Check.Require(listener, "listener");
            Check.Require(listeningPoint, "listeningPoint");
            Check.Require(transaction, "transaction");
            Check.Require(transaction.Request, "transaction.Request");
            ValidateRequest(transaction.Request);

            _routeSet         = new List <SipRecordRouteHeader>();
            _createDate       = DateTime.Now;
            _localSequenceNr  = -1;
            _remoteSequenceNr = -1;

            _listener         = listener;
            _listeningPoint   = listeningPoint;
            _headerFactory    = headerFactory;
            _messageFactory   = messageFactory;
            _addressFactory   = addressFactory;
            _messageSender    = messageSender;
            _firstTransaction = transaction;
            _firstRequest     = transaction.Request;
        }
コード例 #5
0
        protected SipAbstractDialog(SipHeaderFactory headerFactory,
             SipMessageFactory messageFactory,
             SipAddressFactory addressFactory,
             ISipMessageSender messageSender,
             ISipListener listener,
             IPEndPoint listeningPoint,
             ISipTransaction transaction)
        {
            Check.Require(headerFactory, "headerFactory");
            Check.Require(messageFactory, "messageFactory");
            Check.Require(addressFactory, "addressFactory");
            Check.Require(messageSender, "messageSender");
            Check.Require(listener, "listener");
            Check.Require(listeningPoint, "listeningPoint");
            Check.Require(transaction, "transaction");
            Check.Require(transaction.Request, "transaction.Request");
            ValidateRequest(transaction.Request);

            _routeSet = new List<SipRecordRouteHeader>();
            _createDate = DateTime.Now;
            _localSequenceNr = -1;
            _remoteSequenceNr = -1;

            _listener = listener;
            _listeningPoint = listeningPoint;
            _headerFactory = headerFactory;
            _messageFactory = messageFactory;
            _addressFactory = addressFactory;
            _messageSender = messageSender;
            _firstTransaction = transaction;
            _firstRequest = transaction.Request;
        }
コード例 #6
0
        /// <summary>
        /// creates a bye. this is to be sent by the testclient UA
        /// </summary>
        /// <param name="invite"></param>
        /// <param name="ringing"></param>
        /// <returns></returns>
        protected SipRequest CreateByeRequest(SipRequest invite, SipResponse ringing)
        {
            var addressFactory = new SipAddressFactory();
            var headerFactory  = new SipHeaderFactory();
            var messageFactory = new SipMessageFactory();

            var localSequenceNr = invite.CSeq.Sequence;
            /*_remoteSequenceNr remains empty */
            var callId    = invite.CallId.Value;
            var localTag  = invite.From.Tag;
            var remoteUri = invite.To.SipUri;
            var localUri  = invite.From.SipUri;

            var remoteTag    = ringing.To.Tag;
            var remoteTarget = ringing.Contacts.GetTopMost().SipUri;
            var routeSet     = ringing.RecordRoutes.ToList();//refuse looseroutin-less recordroutes

            routeSet.Reverse();

            var cseqHeader   = headerFactory.CreateSCeqHeader(SipMethods.Bye, localSequenceNr + 1);
            var toAddress    = addressFactory.CreateAddress(null, remoteUri);
            var toHeader     = headerFactory.CreateToHeader(toAddress, remoteTag);
            var fromAddress  = addressFactory.CreateAddress(null, localUri);
            var fromHeader   = headerFactory.CreateFromHeader(fromAddress, localTag);
            var callIdheader = headerFactory.CreateCallIdHeader(callId);
            var viaHeader    = new SipViaHeaderBuilder().WithSentBy(_testClientUaEndPoint).Build();
            var requestUri   = remoteUri.Clone();

            var maxForwardsHeader = headerFactory.CreateMaxForwardsHeader();
            var request           = messageFactory.CreateRequest(
                requestUri,
                SipMethods.Bye,
                callIdheader,
                cseqHeader,
                fromHeader,
                toHeader,
                viaHeader,
                maxForwardsHeader);

            foreach (var route in routeSet)
            {
                request.Routes.Add(new SipRouteHeader()
                {
                    SipUri = route.SipUri, Parameters = route.Parameters
                });
            }

            return(request);
        }
コード例 #7
0
ファイル: TxSpecificationBase.cs プロジェクト: goupviet/Hallo
 public TxSpecificationBase()
 {
     MessageSenderMock = new Mock <ISipMessageSender>();
     TxTable           = new SipClientTransactionTable();
     Request           = new SipRequestBuilder()
                         .WithRequestLine
                         (
         new SipRequestLineBuilder()
         .WithMethod(SipMethods.Invite)
         .Build()
                         ).Build();
     TimerFactory   = new TimerFactoryMockBuilder().Build();
     ListenerMock   = new Mock <ISipListener>();
     HeaderFactory  = new SipHeaderFactory();
     MessageFactory = new SipMessageFactory();
 }
コード例 #8
0
        internal SoftPhone(ISipProvider provider, SipMessageFactory messageFactory, SipHeaderFactory headerFactory,
                           SipAddressFactory addressFactory, ISoftPhoneStateProvider stateProvider, ITimerFactory timerFactory, SipListeningPoint listeningPoint)
        {
            ListeningPoint  = listeningPoint;
            _provider       = provider;
            _messageFactory = messageFactory;
            _headerFactory  = headerFactory;
            _addressFactory = addressFactory;
            _stateProvider  = stateProvider;
            _timerFactory   = timerFactory;

            InternalState = _stateProvider.GetIdle();
            InternalState.Initialize(this);
            RetransmitRingingTimer = _timerFactory.CreateRingingTimer(OnRetransmitRinging);
            EndWaitForAckTimer     = _timerFactory.CreateInviteCtxTimeOutTimer(OnWaitForAckTimeOut);

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Initialized.");
            }
        }
コード例 #9
0
        public SipInviteClientDialog(
             ISipTransaction transaction, 
             SipDialogTable dialogTable, 
             SipHeaderFactory headerFactory,
             SipMessageFactory messageFactory,
             SipAddressFactory addressFactory,
             ISipMessageSender messageSender,
             ISipListener listener,
             IPEndPoint listeningPoint)
            : base(headerFactory, messageFactory, addressFactory, messageSender, listener, listeningPoint, transaction)
        {
            Check.Require(transaction, "transaction");
             Check.Require(dialogTable, "dialogTable");
             Check.Require(transaction.Request, "transaction.Request");

             _logger = NLog.LogManager.GetCurrentClassLogger();

             _dialogTable = dialogTable;
             _state = DialogState.Null;
             _topMostVia = (SipViaHeader)transaction.Request.Vias.GetTopMost().Clone();
        }
コード例 #10
0
        public SipInviteClientDialog(
            ISipTransaction transaction,
            SipDialogTable dialogTable,
            SipHeaderFactory headerFactory,
            SipMessageFactory messageFactory,
            SipAddressFactory addressFactory,
            ISipMessageSender messageSender,
            ISipListener listener,
            IPEndPoint listeningPoint)
            : base(headerFactory, messageFactory, addressFactory, messageSender, listener, listeningPoint, transaction)
        {
            Check.Require(transaction, "transaction");
            Check.Require(dialogTable, "dialogTable");
            Check.Require(transaction.Request, "transaction.Request");

            _logger = NLog.LogManager.GetCurrentClassLogger();

            _dialogTable = dialogTable;
            _state       = DialogState.Null;
            _topMostVia  = (SipViaHeader)transaction.Request.Vias.GetTopMost().Clone();
        }
コード例 #11
0
        protected SipRequest CreateRequest(string method)
        {
            /*create the 'INVITE' message*/
            SipAddressFactory addressFactory = _stack.CreateAddressFactory();
            SipHeaderFactory  headerFactory  = _stack.CreateHeaderFactory();
            SipMessageFactory messageFactory = _stack.CreateMessageFactory();

            SipUri     senderSipUri     = addressFactory.CreateUri(string.Empty, new IPEndPoint(_ipAddress, 12345).ToString());
            SipAddress senderSipAddress = addressFactory.CreateAddress(string.Empty, senderSipUri);

            SipUri     receiverSipUri     = addressFactory.CreateUri(string.Empty, new IPEndPoint(_ipAddress, 23456).ToString());
            SipAddress receiverSipAddress = addressFactory.CreateAddress(string.Empty, senderSipUri);

            SipToHeader     toHeader     = headerFactory.CreateToHeader(receiverSipAddress);
            SipFromHeader   fromHeader   = headerFactory.CreateFromHeader(senderSipAddress, SipUtil.CreateTag());
            SipCSeqHeader   cseqHeader   = headerFactory.CreateSCeqHeader(method, 1);
            SipCallIdHeader callIdheader = headerFactory.CreateCallIdHeader(SipUtil.CreateCallId());
            SipViaHeader    viaHeader    = headerFactory.CreateViaHeader(_ipAddress, 12345, SipConstants.Udp,
                                                                         SipUtil.CreateBranch());
            SipMaxForwardsHeader maxForwardsHeader = headerFactory.CreateMaxForwardsHeader();
            SipRequest           request           = messageFactory.CreateRequest(
                receiverSipUri,
                method,
                callIdheader,
                cseqHeader,
                fromHeader,
                toHeader,
                viaHeader,
                maxForwardsHeader);

            if (method == SipMethods.Invite)
            {
                SipContactHeader contactHeader = headerFactory.CreateContactHeader(senderSipUri);
                request.Contacts.Add(contactHeader);
            }

            return(request);
        }
コード例 #12
0
        internal SipInviteClientTransaction(
            SipClientTransactionTable table,
            ISipMessageSender messageSender,
            ISipListener listener,
            SipRequest request,
            ITimerFactory timerFactory,
            SipHeaderFactory headerFactory,
            SipMessageFactory messageFactory)
            : base(table, request, messageSender, listener, timerFactory)
        {
            Check.Require(headerFactory, "headerFactory");
            Check.Require(messageFactory, "messageFactory");

            Check.IsTrue(request.RequestLine.Method == SipMethods.Invite, "Method other then 'INVITE' is not allowed");

            _logger = NLog.LogManager.GetCurrentClassLogger();

            _headerFactory  = headerFactory;
            _messageFactory = messageFactory;

            ReTransmitTimer   = timerFactory.CreateInviteCtxRetransmitTimer(OnReTransmit);
            TimeOutTimer      = timerFactory.CreateInviteCtxTimeOutTimer(OnTimeOut);
            EndCompletedTimer = timerFactory.CreateInviteCtxEndCompletedTimer(OnCompletedEnded);
        }
コード例 #13
0
        internal SipInviteClientTransaction(
            SipClientTransactionTable table,
            ISipMessageSender messageSender,
            ISipListener listener, 
            SipRequest request, 
            ITimerFactory timerFactory, 
            SipHeaderFactory headerFactory,
            SipMessageFactory messageFactory)
            : base(table, request, messageSender, listener, timerFactory)
        {
            Check.Require(headerFactory, "headerFactory");
            Check.Require(messageFactory, "messageFactory");

            Check.IsTrue(request.RequestLine.Method == SipMethods.Invite, "Method other then 'INVITE' is not allowed");

            _logger = NLog.LogManager.GetCurrentClassLogger();

            _headerFactory = headerFactory;
            _messageFactory = messageFactory;

            ReTransmitTimer = timerFactory.CreateInviteCtxRetransmitTimer(OnReTransmit);
            TimeOutTimer = timerFactory.CreateInviteCtxTimeOutTimer(OnTimeOut);
            EndCompletedTimer = timerFactory.CreateInviteCtxEndCompletedTimer(OnCompletedEnded);
        }
コード例 #14
0
 public FakeNetwork()
 {
     _messageFactory = new SipMessageFactory();
     _headerFactory  = new SipHeaderFactory();
 }