Exemple #1
0
        public void SipCoreSettings_LoadConfig()
        {
            try
            {
                Config.SetConfig(@"
&section Core

    LocalContact         = sip:www.lilltek.com:5060;transport=tcp
    OutboundProxy        = sip:sip.lilltek.com:5060
    TraceMode            = ALL
    AutoAuthenticate     = no
    UserAgent            = Foo
    UserName             = Jeff
    Password             = Lill
    ServerTransactionTTL = 10m
    EarlyDialogTTL       = 5s

    &section Transport[0]

        Type       = TCP
        Binding    = 192.168.1.200:SIP
        BufferSize = 16000

        &section Timers
            T1     = 1s
            T2     = 2s
            T4     = 3s
        &endsection

    &endsection

    &section Transport[1]

        Type       = UDP
        Binding    = 127.0.0.1:1234
        BufferSize = 4000
        Timers.T1  = 100ms

    &endsection
&endsection
".Replace('&', '#'));
                SipCoreSettings      settings = SipCoreSettings.LoadConfig("Core");
                SipTransportSettings tSettings;

                Assert.AreEqual("sip:www.lilltek.com:5060;transport=tcp", settings.LocalContact);
                Assert.AreEqual("sip:sip.lilltek.com:5060", (string)settings.OutboundProxyUri);
                Assert.AreEqual(SipTraceMode.All, settings.TraceMode);
                Assert.AreEqual("Foo", settings.UserAgent);
                Assert.IsFalse(settings.AutoAuthenticate);
                Assert.AreEqual("Jeff", settings.UserName);
                Assert.AreEqual("Lill", settings.Password);
                Assert.AreEqual(TimeSpan.FromMinutes(10), settings.ServerTransactionTTL);
                Assert.AreEqual(TimeSpan.FromSeconds(5), settings.EarlyDialogTTL);

                Assert.AreEqual(2, settings.TransportSettings.Length);

                tSettings = settings.TransportSettings[0];
                Assert.AreEqual(SipTransportType.TCP, tSettings.TransportType);
                Assert.AreEqual(new NetworkBinding("192.168.1.200:SIP"), tSettings.Binding);
                Assert.AreEqual(16000, tSettings.BufferSize);

                Assert.AreEqual(TimeSpan.FromSeconds(1), tSettings.BaseTimers.T1);
                Assert.AreEqual(TimeSpan.FromSeconds(2), tSettings.BaseTimers.T2);
                Assert.AreEqual(TimeSpan.FromSeconds(3), tSettings.BaseTimers.T4);

                tSettings = settings.TransportSettings[1];
                Assert.AreEqual(SipTransportType.UDP, tSettings.TransportType);
                Assert.AreEqual(new NetworkBinding("127.0.0.1:1234"), tSettings.Binding);
                Assert.AreEqual(4000, tSettings.BufferSize);

                Assert.AreEqual(TimeSpan.FromMilliseconds(100), tSettings.BaseTimers.T1);

                settings = new SipCoreSettings();
                Assert.AreEqual(NetHelper.GetActiveAdapter().ToString(), settings.LocalContact);
                Assert.IsTrue(settings.AutoAuthenticate);
                Assert.AreEqual("LillTek SIP v" + Helper.GetVersionString(Assembly.GetExecutingAssembly()), settings.UserAgent);
            }
            finally
            {
                Config.SetConfig("");
            }
        }
Exemple #2
0
        public void SipMssGateway_Basic()
        {
            Assert.Inconclusive("Manual Test: Comment this out to perform this test.");

            SipBasicCore  core    = null;
            SipMssGateway gateway = null;
            int           quit;

            try
            {
                Config.SetConfig(@"
&section Core

    LocalContact     = sip:jslill@$(ip-address):8899
    AutoAuthenticate = yes
    UserName         = jslill
    Password         = q0jsrd7y
    Diagnostics      = yes

    &section Transport[0]

        Type    = UDP
        Binding = ANY:8899

    &endsection

    &section Transport[1]

        Type    = TCP
        Binding = ANY:8899

    &endsection

&endsection

&section Gateway

    SpeechServerUri = sip:$(ip-address):5060
    TrunkUri        = sip:sip4.vitelity.net
    Register[0]     = sip:[email protected]

&endsection

".Replace('&', '#'));

                core = new SipBasicCore(SipCoreSettings.LoadConfig("Core"));
                core.SetTraceMode(traceMode);

                gateway = new SipMssGateway(core, SipMssGatewaySettings.LoadConfig("Gateway"));
                gateway.Start();

                quit = 0;
                while (quit == 0)
                {
                    quit = 0;
                    Thread.Sleep(500);  // Break here and manually set quit=1 to terminate the test
                }
            }
            finally
            {
                Config.SetConfig(null);

                if (gateway != null)
                {
                    gateway.Stop();
                }

                if (core != null)
                {
                    core.Stop();
                }
            }
        }