public void SetDialog(SipAbstractDialog dialog)
 {
     _dialog = dialog;
 }
Пример #2
0
        private bool TryGetDialogOnTx(SipRequest request, out SipAbstractDialog dialog)
        {
            dialog = null;

            if (request.To.Tag == null) return false;

            /* merged request: Based on the To tag, the UAS MAY either accept or reject the request.
             * If the request has a tag in the To header field,
             * but the dialog identifier does not match any existing dialogs*/

            if(_logger.IsDebugEnabled)_logger.Debug("Searching the table for a matching dialog...");

            SipAbstractDialog inTableDialog;
            if (_dialogTable.TryGetValue(GetDialogId(request, true), out inTableDialog))
            {
                if (_logger.IsDebugEnabled) _logger.Debug("Found a matching dialog. Setting it on tx.");
                dialog = inTableDialog;
                return true;
            }
            else
            {
                if (_logger.IsDebugEnabled) _logger.Debug("Could not find a matching dialog.");
                /* If the UAS wishes to reject the request because it does not wish to
                   recreate the dialog, it MUST respond to the request with a 481
                   (Call/Transaction Does Not Exist) status code and pass that to the
                   server transaction.
                */
                return false;
            }
        }
Пример #3
0
        private void SendRinging()
        {
            if (_ringingResponse == null)
            {
                _ringingResponse = _inviteRequest.CreateResponse(SipResponseCodes.x180_Ringing);
                _ringingResponse.To.Tag = SipUtil.CreateTag();
                var contactUri = AddressFactory.CreateUri("", MainForm.SipProvider.ListeningPoint.ToString());
                _ringingResponse.Contacts.Add(HeaderFactory.CreateContactHeader(contactUri));

                _inviteTransaction =
                    (SipInviteServerTransaction)SipProvider.CreateServerTransaction(_inviteRequest);
                _dialog = SipProvider.CreateServerDialog(_inviteTransaction);
                _inviteTransaction.SendResponse(_ringingResponse);
            }
            else
            {
                _inviteTransaction.SendResponse(_ringingResponse);
            }
        }
Пример #4
0
 private void SendBye(SipAbstractDialog dialog)
 {
     var byeRequest = dialog.CreateRequest(SipMethods.Bye);
     var ctx = SipProvider.CreateClientTransaction(byeRequest);
     dialog.SendRequest(ctx);
 }
Пример #5
0
 private void RefreshDialogForm(SipAbstractDialog dialog)
 {
     if (dialog == null) return;
     if (dialog.State != DialogState.Null)
     {
         _txtCallId.Text = dialog.CallId;
         _txtLocalTag.Text = dialog.LocalTag;
         _txtRemoteTag.Text = dialog.RemoteTag;
         _txtLocalSeqNr.Text = dialog.LocalSequenceNr.ToString();
         _txtRemoteSeqNr.Text = dialog.RemoteSequenceNr.ToString();
         _txtLocalUri.Text = dialog.LocalUri.FormatToString();
         _txtRemoteUri.Text = dialog.RemoteUri.FormatToString();
         _txtRemoteTarget.Text = dialog.RemoteTarget.FormatToString();
         StringBuilder sb = new StringBuilder();
         dialog.RouteSet.ForEach(r => sb.AppendLine(r.FormatBodyToString()));
         _txtRouteSet.Text = sb.ToString();
     }
     else
     {
         _txtCallId.Text = _txtLocalTag.Text = _txtRemoteTag.Text = _txtLocalSeqNr.Text =
        _txtRemoteSeqNr.Text =_txtLocalUri.Text = _txtRemoteUri.Text =_txtRemoteTarget.Text = "NULL";
         _txtRouteSet.Text = "NULL";
     }
 }
Пример #6
0
        private void Invite()
        {
            FormHelper.ValidateCondition(SipUtil.IsSipUri(_txtFromUri.Text), "From-uri");

                FormHelper.ValidateCondition(SipUtil.IsSipUri(_txtToUri.Text), "To-uri");

                var fromUri = SipUtil.ParseSipUri(_txtFromUri.Text);
                var toUri = SipUtil.ParseSipUri(_txtToUri.Text);

                if (_chkPeerToPeer.Checked) FormHelper.ValidateCondition(SipUtil.IsIpEndPoint(toUri.Host), "To-uri");

                var requestUri = toUri;
                var toAddress = AddressFactory.CreateAddress(_txtToAlias.Text, toUri);
                var fromAddress = AddressFactory.CreateAddress(_txtFromAlias.Text, fromUri);
                var toHeader = HeaderFactory.CreateToHeader(toAddress);
                var fromHeader = HeaderFactory.CreateFromHeader(fromAddress, SipUtil.CreateTag());
                var cseqHeader = HeaderFactory.CreateSCeqHeader(SipMethods.Invite, ++commandSequence);
                var callIdheader = HeaderFactory.CreateCallIdHeader(SipUtil.CreateCallId());
                var viaHeader = HeaderFactory.CreateViaHeader(SipProvider.ListeningPoint.Address,
                                                              SipProvider.ListeningPoint.Port, SipConstants.Udp,
                                                              SipUtil.CreateBranch());
                var maxForwardsHeader = HeaderFactory.CreateMaxForwardsHeader(1);
                var request = MessageFactory.CreateRequest(
                    requestUri,
                    SipMethods.Invite,
                    callIdheader,
                    cseqHeader,
                    fromHeader,
                    toHeader,
                    viaHeader,
                    maxForwardsHeader);

                /*add routes and contacts*/
                if (!_chkPeerToPeer.Checked)
                {
                    var proxyServerUri = AddressFactory.CreateUri(null, MainForm.SipStack.OutBoundProxy.ToString());
                    proxyServerUri.IsLooseRouting = true;
                    var routeHeader = HeaderFactory.CreateRouteHeader(proxyServerUri);
                    request.Routes.Add(routeHeader);
                }
                var contactUri = AddressFactory.CreateUri(fromUri.User, viaHeader.SentBy.ToString());
                var contactHeader = HeaderFactory.CreateContactHeader(contactUri);
                request.Contacts.Add(contactHeader);

                var transaction = SipProvider.CreateClientTransaction(request);
                _dialog = SipProvider.CreateClientDialog(transaction);
                transaction.SendRequest();
        }