コード例 #1
0
ファイル: SoftPhoneFactory.cs プロジェクト: HNeukermans/Hallo
 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);
 }
コード例 #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));
     }
 }
コード例 #3
0
ファイル: SipProvider.cs プロジェクト: HNeukermans/Hallo
        //want follow the jain-sip implementation. I just use a guid. SipUtil.CreateCallId();
        //public SipCallIdHeader GetNewCallId()
        //{
        //    String callId = SipUtil.GenerateCallIdentifier(this.getListeningPoint()
        //            .getIPAddress());
        //    SipCallIdHeader callid = new SipCallIdHeader();
        //    return callid;
        //}
        internal SipProvider(SipStack stack, ISipContextSource contextSource)
        {
            Check.Require(stack, "stack");
            Check.Require(contextSource, "contextSource");

            _stack = stack;
            _contextSource = contextSource;
            contextSource.NewContextReceived +=(s,e) => OnNewContextReceived(e.Context);
            contextSource.UnhandledException += (s, e) => OnContextSourceUnhandledException(e.Exception);

            _ctxTable = new SipClientTransactionTable();
            _stxTable = new SipServerTransactionTable();
            _dialogTable = new SipDialogTable();
        }
コード例 #4
0
        //want follow the jain-sip implementation. I just use a guid. SipUtil.CreateCallId();
        //public SipCallIdHeader GetNewCallId()
        //{
        //    String callId = SipUtil.GenerateCallIdentifier(this.getListeningPoint()
        //            .getIPAddress());
        //    SipCallIdHeader callid = new SipCallIdHeader();

        //    return callid;
        //}

        internal SipProvider(SipStack stack, ISipContextSource contextSource)
        {
            Check.Require(stack, "stack");
            Check.Require(contextSource, "contextSource");

            _stack         = stack;
            _contextSource = contextSource;
            contextSource.NewContextReceived += (s, e) => OnNewContextReceived(e.Context);
            contextSource.UnhandledException += (s, e) => OnContextSourceUnhandledException(e.Exception);

            _ctxTable    = new SipClientTransactionTable();
            _stxTable    = new SipServerTransactionTable();
            _dialogTable = new SipDialogTable();
        }
コード例 #5
0
        protected override void Given()
        {
            _packet1 = new FakeUdpPacket("1", DefaultRemoteEp);
            _packet2 = new FakeUdpPacket("1", DefaultRemoteEp);

            var fakePackets = new Stack<FakeUdpPacket>();
            fakePackets.Push(_packet1);
            fakePackets.Push(_packet2);
            _fakeSocketImpl = new FakeSocketImpl(fakePackets);

            _messageprocessor = new Mock<IUdpMessageProcessor>();

            _sipStack = new SipStack();
            _udpServer = new UdpServer(_sipStack, _listeningPoint, _fakeSocketImpl, _messageprocessor.Object);
        }
コード例 #6
0
ファイル: WorkShopBase.cs プロジェクト: HNeukermans/Hallo
        public void Setup()
        {
            _ipAddress =
                Dns.GetHostAddresses(string.Empty).Where(a => a.AddressFamily == AddressFamily.InterNetwork).First();

            /*create stack*/
            _stack = new SipStack();

            /*create sipproviders*/
            _senderProvider = _stack.CreateSipProvider(_stack.CreateUdpListeningPoint(_ipAddress, 12345));
            _receiverProvider = _stack.CreateSipProvider(_stack.CreateUdpListeningPoint(_ipAddress, 23456));

            /*start both providers*/
            _senderProvider.Start();
            _receiverProvider.Start();
        }
コード例 #7
0
ファイル: SipServer.cs プロジェクト: HNeukermans/Hallo
        public void Start()
        {
            if(_configuration == null) throw new InvalidOperationException("The server is not configured.");

            _stack = new SipStack();
            _stack.MaxWorkerThreads = _configuration.MaxThreadPoolSize;
            _stack.MinWorkerThreads = _configuration.MinThreadPoolSize;
            _stack.EnableThreadPoolPerformanceCounters = _configuration.EnableThreadPoolPerformanceCounters;
             var listeningPoint = _stack.CreateUdpListeningPoint(_ipEndPoint);
            _provider = (SipProvider)_stack.CreateSipProvider(listeningPoint);
            _listener = new SipServerListener();
            _registrar = InitializeRegistrar();
            _listener.AddRequestHandler(_registrar);
            _provider.AddSipListener(_listener);
            //_stack.Start();
        }
コード例 #8
0
 protected override void Given()
 {
     _contextSource = new FakeSipContextSource();
     _sipStack = new SipStack();
     _provider = new SipProvider(_sipStack, _contextSource);
     _inviteRequest = CreateInviteRequest();
     BeforeCreateInviteTransaction();
     _inviteTransaction = _provider.CreateClientTransaction(_inviteRequest).As<SipInviteClientTransaction>();
     _dialog = _provider.CreateClientDialog(_inviteTransaction);
     _inviteTransaction.SendRequest();
     GivenOverride();
 }
コード例 #9
0
ファイル: ClientMainForm.cs プロジェクト: HNeukermans/Hallo
        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;
        }