Example #1
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            WriteToLog(">>>>" + SipFormatter.FormatMessageEnvelope(requestEvent.Request) + Environment.NewLine);
            requestEvent.Response  = requestEvent.Request.CreateResponse(SipResponseCodes.x200_Ok);
            requestEvent.IsHandled = true;
            _sipProvider.SendResponse(requestEvent.Response);

            WriteToLog("<<<<" + SipFormatter.FormatMessageEnvelope(requestEvent.Response) + Environment.NewLine);
        }
Example #2
0
        private void WriteToLog(IList <SipMessage> messages)
        {
            var sb = new StringBuilder();

            foreach (var m in messages)
            {
                sb.AppendLine(SipFormatter.FormatMessageEnvelope(m));
            }

            _txtLog.Text          += sb.ToString();
            _txtLog.SelectionStart = _txtLog.Text.Length;
            _txtLog.ScrollToCaret();
        }
Example #3
0
        private void _btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                var requestUri   = AddressFactory.CreateUri(null, "registrar." + MainForm.Configuration.RegistrarDomain);
                var toAddressUri = AddressFactory.CreateUri("hannes", MainForm.Configuration.RegistrarDomain);
                var toAddress    = AddressFactory.CreateAddress("hannes", toAddressUri);
                var toHeader     = HeaderFactory.CreateToHeader(toAddress);
                var fromHeader   = HeaderFactory.CreateFromHeader(toAddress, SipUtil.CreateTag());
                var cseqHeader   = HeaderFactory.CreateSCeqHeader(SipMethods.Register, 1028);
                var callId       = SipUtil.CreateCallId();
                var callIdheader = HeaderFactory.CreateCallIdHeader(callId);
                var viaHeader    = HeaderFactory.CreateViaHeader(SipProvider.ListeningPoint.Address, SipProvider.ListeningPoint.Port, SipConstants.Udp,
                                                                 SipUtil.CreateBranch());
                var maxForwardsHeader = HeaderFactory.CreateMaxForwardsHeader();
                var request           = MessageFactory.CreateRequest(
                    requestUri,
                    SipMethods.Register,
                    callIdheader,
                    cseqHeader,
                    fromHeader,
                    toHeader,
                    viaHeader,
                    maxForwardsHeader);

                var proxyServerUri = AddressFactory.CreateUri(null, MainForm.SipStack.OutBoundProxy.ToString());
                var localHostUri   = AddressFactory.CreateUri(null, MainForm.SipProvider.ListeningPoint.ToString());
                var routeHeader    = HeaderFactory.CreateRouteHeader(proxyServerUri);
                var contactHeader  = HeaderFactory.CreateContactHeader(localHostUri);
                request.Routes.Add(routeHeader);
                request.Contacts.Add(contactHeader);

                EventAggregator.Instance.Publish(
                    new LogEvent(">>>>" + SipFormatter.FormatMessageEnvelope(request) + Environment.NewLine));

                if (_chbSendStateFull.Checked)
                {
                    var transaction = SipProvider.CreateClientTransaction(request);
                    transaction.SendRequest();
                }
                else
                {
                    SipProvider.SendRequest(request);
                }
            }
            catch (Exception ex)
            {
                MainForm.HandleException(ex);
            }
        }
        public void Expect_all_request_are_equal()
        {
            string first = null;

            foreach (var request in _subjectFoldedRequest)
            {
                if (first == null)
                {
                    first = SipFormatter.FormatMessageEnvelope(request);
                }
                else
                {
                    var other = SipFormatter.FormatMessageEnvelope(request);
                    Assert.AreEqual(other, first);
                }
            }
        }
        public void Expect_the_order_of_the_route_headers_to_be_preserved()
        {
            string first = null;

            foreach (var request in _requestUnderTest)
            {
                if (first == null)
                {
                    first = SipFormatter.FormatMessageEnvelope(request);
                }
                else
                {
                    var other = SipFormatter.FormatMessageEnvelope(request);
                    Assert.AreEqual(other, first);
                }
            }
        }
Example #6
0
        public void ProcessTimeOut(SipTimeOutEvent timeOutEvent)
        {
            EventAggregator.Instance.Publish(new LogEvent("<<<< [RECEIVED TIMEOUT] " + SipFormatter.FormatMessageEnvelope(timeOutEvent.Request)));

            _listener.ProcessTimeOut(timeOutEvent);
        }
Example #7
0
        public void ProcessResponse(SipResponseEvent responseEvent)
        {
            EventAggregator.Instance.Publish(new LogEvent("<<<< [RECEIVED RESPONSE]" + SipFormatter.FormatMessageEnvelope(responseEvent.Response)));

            _listener.ProcessResponse(responseEvent);
        }
Example #8
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            EventAggregator.Instance.Publish(new LogEvent("<<<< [RECEIVED REQUEST] " + SipFormatter.FormatMessageEnvelope(requestEvent.Request)));

            _listener.ProcessRequest(requestEvent);

            //         EventAggregator.Instance.Publish(new LogEvent(">>>> [SEND RESPONSE] " + SipFormatter.FormatMessageEnvelope(response)));

            //MainForm.SendMessage(new LogMessage() { Text = "<<<<" + SipFormatter.FormatMessageEnvelope(requestEvent.Response) });
        }
Example #9
0
        private void _lnkTemplateRegister_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var request = ApplyActions(CreateRegisterRequest());

            _txtMessage.Text = SipFormatter.FormatMessageEnvelope(request, true);
        }
Example #10
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            EventAggregator.Instance.Publish(new LogEvent("<<<< [RECEIVED REQUEST] " + SipFormatter.FormatMessageEnvelope(requestEvent.Request)));

            if (_siplistener != null)
            {
                _siplistener.ProcessRequest(requestEvent);
            }

            //MainForm.SendMessage(new LogMessage() { Text = "<<<<" + SipFormatter.FormatMessageEnvelope(requestEvent.Response) });
        }