Beispiel #1
0
 protected Call(CallingAPI api, string nodeID, string callID)
 {
     mLogger = SignalWireLogging.CreateLogger <Client>();
     mAPI    = api;
     mNodeID = nodeID;
     mID     = callID;
 }
        public static int Main(string[] args)
        {
            // Setup logging to console for Blade and SignalWire
            BladeLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);
            SignalWireLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);

            // Create a logger for this entry point class type
            Logger = SignalWireLogging.CreateLogger <Program>();

            Logger.LogInformation("Started");

            Stopwatch timer = Stopwatch.StartNew();

            // Create the TestConsumer
            TestConsumer consumer = null;

            try { consumer = new TestConsumer(); }
            catch (Exception) { return(-1); }

            // Run a backgrounded task that will stop the consumer after 1 minute
            Task.Run(() =>
            {
                // Wait more than long enough for the test to be completed
                if (!consumer.Completed.Wait(TimeSpan.FromMinutes(1)))
                {
                    Logger.LogError("Test timed out");
                }
                consumer.Stop();
            });

            try
            {
                // Run the TestConsumer which blocks until it is stopped
                consumer.Run();
            }
            catch (Exception exc)
            {
                Logger.LogError(exc, "Consumer run exception");
            }

            timer.Stop();

            // Report test outcome
            if (!consumer.Successful)
            {
                Logger.LogError("Completed unsuccessfully: {0} elapsed", timer.Elapsed);
            }
            else
            {
                Logger.LogInformation("Completed successfully: {0} elapsed", timer.Elapsed);
            }


#if DEBUG
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey(true);
#endif
            return(consumer.Successful ? 0 : -1);
        }
Beispiel #3
0
        public static int Main(string[] args)
        {
            // Setup logging to console for Blade and SignalWire
            BladeLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);
            SignalWireLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);

            // Create a logger for this entry point class type
            Logger = SignalWireLogging.CreateLogger <Program>();

            Logger.LogInformation("Started");

            Stopwatch timer = Stopwatch.StartNew();

            // Use environment variables
            string host    = Environment.GetEnvironmentVariable("TEST_HOST");
            string project = Environment.GetEnvironmentVariable("TEST_PROJECT");
            string token   = Environment.GetEnvironmentVariable("TEST_TOKEN");
            string context = Environment.GetEnvironmentVariable("TEST_CONTEXT");

            // Make sure we have mandatory options filled in
            if (host == null)
            {
                Logger.LogError("Missing 'TEST_HOST' environment variable");
                return(-1);
            }
            if (project == null)
            {
                Logger.LogError("Missing 'TEST_PROJECT' environment variable");
                return(-1);
            }
            if (token == null)
            {
                Logger.LogError("Missing 'TEST_TOKEN' environment variable");
                return(-1);
            }
            if (context == null)
            {
                Logger.LogError("Missing 'TEST_CONTEXT' environment variable");
                return(-1);
            }

            // Create the TestConsumer
            TestConsumer consumer = new TestConsumer(host, project, token, context);

            // Run a backgrounded task that will stop the consumer after 2 minutes
            Task.Run(() =>
            {
                // Wait more than long enough for the test to be completed
                if (!consumer.Completed.Wait(TimeSpan.FromMinutes(2)))
                {
                    Logger.LogError("Test timed out");
                }
                consumer.Stop();
            });

            try
            {
                // Run the TestConsumer which blocks until it is stopped
                consumer.Run();
            }
            catch (Exception exc)
            {
                Logger.LogError(exc, "Consumer run exception");
            }

            timer.Stop();

            // Report test outcome
            if (!consumer.Successful)
            {
                Logger.LogError("Completed unsuccessfully: {0} elapsed", timer.Elapsed);
            }
            else
            {
                Logger.LogInformation("Completed successfully: {0} elapsed", timer.Elapsed);
            }

#if DEBUG
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey(true);
#endif
            return(consumer.Successful ? 0 : -1);
        }
Beispiel #4
0
        public static int Main(string[] args)
        {
            // Setup logging to console for Blade and SignalWire
            BladeLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);
            SignalWireLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);

            // Create a logger for this entry point class type
            Logger = SignalWireLogging.CreateLogger <Program>();

            Logger.LogInformation("Started");

            Stopwatch timer = Stopwatch.StartNew();

            // Use environment variables
            string session_host    = Environment.GetEnvironmentVariable("SWCLIENT_TEST_SESSION_HOST");
            string session_project = Environment.GetEnvironmentVariable("SWCLIENT_TEST_SESSION_PROJECT");
            string session_token   = Environment.GetEnvironmentVariable("SWCLIENT_TEST_SESSION_TOKEN");

            sCallReceiveContext = Environment.GetEnvironmentVariable("SWCLIENT_TEST_CALLRECEIVE_CONTEXT");
            sCallToNumber       = Environment.GetEnvironmentVariable("SWCLIENT_TEST_CALL_TO_NUMBER");
            sCallFromNumber     = Environment.GetEnvironmentVariable("SWCLIENT_TEST_CALL_FROM_NUMBER");

            // Make sure we have mandatory options filled in
            if (session_host == null)
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_SESSION_HOST' environment variable");
                return(-1);
            }
            if (session_project == null)
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_SESSION_PROJECT' environment variable");
                return(-1);
            }
            if (session_token == null)
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_SESSION_TOKEN' environment variable");
                return(-1);
            }
            if (sCallReceiveContext == null)
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_CALLRECEIVE_CONTEXT' environment variable");
                return(-1);
            }
            if (sCallToNumber == null)
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_CALL_TO_NUMBER' environment variable");
                return(-1);
            }
            if (sCallFromNumber == null)
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_CALL_FROM_NUMBER' environment variable");
                return(-1);
            }

            try
            {
                // Create the client
                using (sClient = new Client(session_host, session_project, session_token))
                {
                    // Setup callbacks before the client is started
                    sClient.OnReady += Client_OnReady;

                    // Start the client
                    sClient.Connect();

                    // Wait more than long enough for the test to be completed
                    if (!sCompleted.Wait(TimeSpan.FromMinutes(5)))
                    {
                        Logger.LogError("Test timed out");
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.LogError(exc, "Client startup failed");
            }

            timer.Stop();

            // Report test outcome
            if (!sSuccessful)
            {
                Logger.LogError("Completed unsuccessfully: {0} elapsed", timer.Elapsed);
            }
            else
            {
                Logger.LogInformation("Completed successfully: {0} elapsed", timer.Elapsed);
            }

#if DEBUG
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey(true);
#endif
            return(sSuccessful ? 0 : -1);
        }
Beispiel #5
0
        public static int Main(string[] args)
        {
            // Setup logging to console for Blade and SignalWire
            BladeLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);
            SignalWireLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);

            // Create a logger for this entry point class type
            Logger = SignalWireLogging.CreateLogger <Program>();

            Logger.LogInformation("Started");

            Stopwatch timer = Stopwatch.StartNew();

            // Use environment variables
            sSessionHost    = Environment.GetEnvironmentVariable("SWCLIENT_TEST_SESSION_HOST");
            sSessionProject = Environment.GetEnvironmentVariable("SWCLIENT_TEST_SESSION_PROJECT");
            sJWTTokenServer = Environment.GetEnvironmentVariable("SWCLIENT_TEST_JWT_TOKEN");
            sJWTURL         = Environment.GetEnvironmentVariable("SWCLIENT_TEST_JWT_URL");

            // Make sure we have mandatory options filled in
            if (string.IsNullOrWhiteSpace(sSessionHost))
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_SESSION_HOST' environment variable");
                return(-1);
            }
            if (string.IsNullOrWhiteSpace(sSessionProject))
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_SESSION_PROJECT' environment variable");
                return(-1);
            }
            if (string.IsNullOrWhiteSpace(sJWTTokenServer))
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_JWT_TOKEN' environment variable");
                return(-1);
            }
            if (string.IsNullOrWhiteSpace(sJWTURL))
            {
                Logger.LogError("Missing 'SWCLIENT_TEST_JWT_URL' environment variable");
                return(-1);
            }


            if (!JWTPost(sJWTURL, sSessionProject, sJWTTokenServer, out sJWTTokenClient, out sJWTRefreshToken))
            {
                sCompleted.Set();
            }
            else
            {
                Logger.LogInformation("Successfully obtained JWT token: {0}", sJWTTokenClient);

                try
                {
                    // Create the client
                    using (sClient = new Client(sSessionProject, sJWTTokenClient, host: sSessionHost, jwt: true))
                    {
                        // Setup callbacks before the client is started
                        sClient.OnReady += Client_OnReady;

                        // Start the client
                        sClient.Connect();

                        // Wait more than long enough for the test to be completed
                        //if (!sCompleted.Wait(TimeSpan.FromMinutes(2))) Logger.LogError("Test timed out");
                        sCompleted.Wait();
                    }
                }
                catch (Exception exc)
                {
                    Logger.LogError(exc, "Client startup failed");
                }
            }

            timer.Stop();

            // Report test outcome
            if (!sSuccessful)
            {
                Logger.LogError("Completed unsuccessfully: {0} elapsed", timer.Elapsed);
            }
            else
            {
                Logger.LogInformation("Completed successfully: {0} elapsed", timer.Elapsed);
            }

#if DEBUG
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey(true);
#endif
            return(sSuccessful ? 0 : -1);
        }
Beispiel #6
0
        public static int Main(string[] args)
        {
            // Setup logging to console for Blade and SignalWire
            BladeLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);
            SignalWireLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);

            // Create a logger for this entry point class type
            Logger = SignalWireLogging.CreateLogger <Program>();

            Logger.LogInformation("Started");

            Stopwatch timer = Stopwatch.StartNew();

            // Use environment variables
            string session_host    = Environment.GetEnvironmentVariable("TEST_SESSION_HOST");
            string session_project = Environment.GetEnvironmentVariable("TEST_SESSION_PROJECT");
            string session_token   = Environment.GetEnvironmentVariable("TEST_SESSION_TOKEN");

            sCallReceiveContext  = Environment.GetEnvironmentVariable("TEST_CONTEXT");
            sCallToHumanNumber   = Environment.GetEnvironmentVariable("TEST_TO_HUMAN_NUMBER");
            sCallToMachineNumber = Environment.GetEnvironmentVariable("TEST_TO_MACHINE_NUMBER");
            sCallToFaxNumber     = Environment.GetEnvironmentVariable("TEST_TO_FAX_NUMBER");
            sCallToDigitNumber   = Environment.GetEnvironmentVariable("TEST_TO_DIGIT_NUMBER");
            sCallFromNumber      = Environment.GetEnvironmentVariable("TEST_FROM_NUMBER");

            // Make sure we have mandatory options filled in
            if (session_host == null)
            {
                Logger.LogError("Missing 'TEST_SESSION_HOST' environment variable");
                return(-1);
            }
            if (session_project == null)
            {
                Logger.LogError("Missing 'TEST_SESSION_PROJECT' environment variable");
                return(-1);
            }
            if (session_token == null)
            {
                Logger.LogError("Missing 'TEST_SESSION_TOKEN' environment variable");
                return(-1);
            }
            if (sCallReceiveContext == null)
            {
                Logger.LogError("Missing 'TEST_CONTEXT' environment variable");
                return(-1);
            }
            if (sCallToHumanNumber == null)
            {
                Logger.LogError("Missing 'TEST_TO_HUMAN_NUMBER' environment variable");
                return(-1);
            }
            if (sCallToMachineNumber == null)
            {
                Logger.LogError("Missing 'TEST_TO_MACHINE_NUMBER' environment variable");
                return(-1);
            }
            if (sCallToFaxNumber == null)
            {
                Logger.LogError("Missing 'TEST_TO_FAX_NUMBER' environment variable");
                return(-1);
            }
            if (sCallToDigitNumber == null)
            {
                Logger.LogError("Missing 'TEST_TO_DIGIT_NUMBER' environment variable");
                return(-1);
            }
            if (sCallFromNumber == null)
            {
                Logger.LogError("Missing 'TEST_FROM_NUMBER' environment variable");
                return(-1);
            }

            try
            {
                // Create the client
                using (sClient = new Client(session_project, session_token, host: session_host))
                {
                    // Setup callbacks before the client is started
                    sClient.OnReady += Client_OnReady;

                    // Start the client
                    sClient.Connect();

                    // Wait more than long enough for the tests to be completed
                    var handles = new[] {
                        sHumanCompleted.WaitHandle,
                        sMachineCompleted.WaitHandle,
                        sFaxCompleted.WaitHandle,
                        sDigitCompleted.WaitHandle,
                    };
                    if (!WaitHandle.WaitAll(handles, TimeSpan.FromMinutes(2)))
                    {
                        Logger.LogError("At least one test timed out");
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.LogError(exc, "Client startup failed");
            }

            timer.Stop();

            Logger.LogInformation("[Report] Tests completed, {1} elapsed", timer.Elapsed);

            // Report test outcomes
            Action <string, bool> report = (id, success) =>
            {
                if (!success)
                {
                    Logger.LogError("[Report] {0} completed unsuccessfully", id);
                }
                else
                {
                    Logger.LogInformation("[Report] {0} completed successfully", id);
                }
            };

            if (sRunHuman)
            {
                report("Human", sHumanSuccessful);
            }
            if (sRunMachine)
            {
                report("Machine", sMachineSuccessful);
            }
            if (sRunFax)
            {
                report("Fax", sFaxSuccessful);
            }
            if (sRunDigit)
            {
                report("Digit", sDigitSuccessful);
            }

#if DEBUG
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey(true);
#endif
            return
                (new[] {
                sHumanSuccessful,
                sMachineSuccessful,
                sFaxSuccessful,
                sDigitSuccessful,
            }.All(b => b) ? 0 : -1);
        }
Beispiel #7
0
 protected Call(CallingAPI api, string temporaryCallID)
 {
     mLogger      = SignalWireLogging.CreateLogger <Client>();
     mAPI         = api;
     mTemporaryID = temporaryCallID;
 }
Beispiel #8
0
        public static void Main(string[] args)
        {
            // Setup logging to console for Blade and SignalWire
            BladeLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);
            SignalWireLogging.LoggerFactory.AddSimpleConsole(LogLevel.Trace);

            // Create a logger for this entry point class type
            Logger = SignalWireLogging.CreateLogger <Program>();

            Logger.LogInformation("Started");

            // Use environment variables
            string session_host    = Environment.GetEnvironmentVariable("SWCLIENT_EXAMPLE_SESSION_HOST");
            string session_project = Environment.GetEnvironmentVariable("SWCLIENT_EXAMPLE_SESSION_PROJECT");
            string session_token   = Environment.GetEnvironmentVariable("SWCLIENT_EXAMPLE_SESSION_TOKEN");

            sCallReceiveContext = Environment.GetEnvironmentVariable("SWCLIENT_EXAMPLE_CALLRECEIVE_CONTEXT");
            sCallToNumber       = Environment.GetEnvironmentVariable("SWCLIENT_EXAMPLE_CALL_TO_NUMBER");
            sCallFromNumber     = Environment.GetEnvironmentVariable("SWCLIENT_EXAMPLE_CALL_FROM_NUMBER");

            // Make sure we have mandatory options filled in
            if (session_host == null)
            {
                Logger.LogError("Missing 'SWCLIENT_EXAMPLE_SESSION_HOST' environment variable");
                return;
            }
            if (session_project == null)
            {
                Logger.LogError("Missing 'SWCLIENT_EXAMPLE_SESSION_PROJECT' environment variable");
                return;
            }
            if (session_token == null)
            {
                Logger.LogError("Missing 'SWCLIENT_EXAMPLE_SESSION_TOKEN' environment variable");
                return;
            }
            if (sCallReceiveContext == null)
            {
                Logger.LogError("Missing 'SWCLIENT_EXAMPLE_CALLRECEIVE_CONTEXT' environment variable");
                return;
            }
            if (sCallToNumber == null)
            {
                Logger.LogError("Missing 'SWCLIENT_EXAMPLE_CALL_TO_NUMBER' environment variable");
                return;
            }
            if (sCallFromNumber == null)
            {
                Logger.LogError("Missing 'SWCLIENT_EXAMPLE_CALL_FROM_NUMBER' environment variable");
                return;
            }

            try
            {
                // Create the client
                using (sClient = new Client(session_host, session_project, session_token))
                {
                    // Setup callbacks before the client is started
                    sClient.OnReady += Client_OnReady;

                    // Start the client
                    sClient.Connect();

                    Console.ReadKey(true);
                }
            }
            catch (Exception exc)
            {
                Logger.LogError(exc, "Client startup failed");
            }
        }