Пример #1
0
        public SipRequest CreateRequest(SipUri requestUri, string method, SipCallIdHeader callId, SipCSeqHeader cSeq, SipFromHeader from, SipToHeader to, SipViaHeader viaHeader, SipMaxForwardsHeader maxForwards)
        {
            Check.Require(requestUri, "requestUri");
             Check.Require(method, "method");
             Check.Require(callId, "callId");
             Check.Require(cSeq, "cseq");
             Check.Require(from, "from");
             Check.Require(to , "to");
             Check.Require( viaHeader,"viaHeader");
             Check.Require(maxForwards,  "maxforwards");

            var message = new SipRequest();
            message.RequestLine.Method = method;
            message.RequestLine.Uri = requestUri;
            message.RequestLine.Version = SipConstants.SipTwoZeroString;
            message.CallId = callId;
            message.To = to;
            message.From = from;
            message.CSeq = cSeq;
            message.Vias.SetTopMost(viaHeader);
            message.MaxForwards = maxForwards;
            return message;
        }
Пример #2
0
        public SipViaHeader CreateViaHeader(IPAddress host, int? port, string transport, string branch)
        {
            Check.Require(host, "host");
            Check.NotNullOrEmpty(transport, "transport");
            Check.NotNullOrEmpty(branch, "branch");

            SipViaHeader h = new SipViaHeader();
            if(branch != null) h.Branch = branch;
            h.SentBy = new System.Net.IPEndPoint(host, port.HasValue ? port.Value : 5060);
            h.Transport = transport;
            return h;
        }
Пример #3
0
        public SipRequest CreateRequest(string method, SipViaHeader viaheader = null)
        {
            if (State < DialogState.Early) throw new InvalidOperationException("The dialog is unable to create the request. A dialog in 'NULL' state can not create requests.");

            Check.IsTrue(SipMethods.IsMethod(method), "method argument must be a SIP method");

            var cseqHeader = _headerFactory.CreateSCeqHeader(method, _localSequenceNr);
            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 =  viaheader ?? _headerFactory.CreateViaHeader(_listeningPoint, SipConstants.Udp, SipUtil.CreateBranch());
            var requestUri = _remoteUri.Clone();

            var maxForwardsHeader = _headerFactory.CreateMaxForwardsHeader();
            var request = _messageFactory.CreateRequest(
                requestUri,
                method,
                callIdheader,
                cseqHeader,
                fromHeader,
                toHeader,
                viaHeader,
                maxForwardsHeader);

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

            return request;
        }