Ejemplo n.º 1
0
        public static ISoftPhone CreateSoftPhone(IPEndPoint listeningPoint)
        {
            var sipStack          = new SipStack();
            var sipListeningPoint = sipStack.CreateUdpListeningPoint(listeningPoint);
            var provider          = sipStack.CreateSipProvider(sipListeningPoint);

            return(new SoftPhone(provider, sipStack.CreateMessageFactory(), sipStack.CreateHeaderFactory(), sipStack.CreateAddressFactory(), new SoftPhoneStateProvider(), new TimerFactory(), sipListeningPoint));
        }
Ejemplo n.º 2
0
        protected override void When()
        {
            var f = new SipStack();
            var messageFacttory = f.CreateMessageFactory();
            var headerFactory   = f.CreateHeaderFactory();

            foreach (string message in _messages)
            {
                var parserContext = new SipParserContext(messageFacttory, headerFactory);
                parserContext.ParseCompleted += (s, e) => _subjectFoldedRequest.Add((SipRequest)e.Message);
                parserContext.Parse(SipFormatter.FormatToBytes(message));
            }
        }
Ejemplo n.º 3
0
        private void _btnStartStop_Click(object sender, EventArgs e)
        {
            if (!_isStarted)
            {
                var ipEndPoint    = SipUtil.ParseIpEndPoint(Configuration.BindIpEndPoint);
                var outboundProxy = SipUtil.ParseIpEndPoint(Configuration.OutboundProxyIpEndPoint);
                SipStack = new SipStack();
                var listeningPoint = SipStack.CreateUdpListeningPoint(ipEndPoint);
                SipStack.MaxWorkerThreads = Configuration.MaxThreadPoolSize;
                SipStack.MinWorkerThreads = Configuration.MinThreadPoolSize;
                SipStack.OutBoundProxy    = outboundProxy;
                SipStack.EnableThreadPoolPerformanceCounters = Configuration.EnableThreadPoolPerformanceCounters;
                //SipStack.IsStateFull = Configuration.IsStateFull;
                SipProvider     = (SipProvider)SipStack.CreateSipProvider(listeningPoint);
                MainSipListener = new SipPipeLineListener(this);
                SipProvider.AddSipListener(MainSipListener);
                SipProvider.AddExceptionHandler(this);
                SipProvider.Start();


                HeaderFactory  = SipStack.CreateHeaderFactory();
                MessageFactory = SipStack.CreateMessageFactory();
                AddressFactory = SipStack.CreateAddressFactory();

                ExecuteActionHelper.ExecuteAction(delegate()
                {
                    FormsManager.OpenForm(typeof(LogForm), null);
                });

                _lblIpAddress.Text = string.Format("IP:{0}", ipEndPoint.ToString());
            }
            else
            {
                SipProvider.Stop();
            }

            _isStarted             = !_isStarted;
            _btnStartStop.Text     = _isStarted ? "Stop" : "Start";
            _grbNavigation.Enabled = _isStarted;
        }
Ejemplo n.º 4
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);
        }