Esempio n. 1
0
        public override bool Startup(ApplicationBase app, IConfiguration?config)
        {
            Logger?.Info("Starting HTTP Server");
            server = new HTTPRPCServer("localhost", 5010);
            server.Run();

            Logger?.Info("Starting Client Sendings by Timer");
            var cli        = HTTPRPCClient.Client <IHttpAPI>(new Uri("http://localhost:5010/api"));
            var inprogress = false;

            timer = new Timer((st) => {
                if (inprogress)
                {
                    return;
                }
                inprogress = true;
                try
                {
                    cnt++;
                    var sw = Stopwatch.StartNew();
                    var r  = cli.Test(cnt);
                    Logger?.Info($"RPC Call Executed in {sw.ElapsedMilliseconds} ms. Result: {r.ToString("HH:mm:ss",CultureInfo.InvariantCulture)}");
                }
                #pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception ex)
                {
                    Logger?.Error(ex.Message);
                }
                #pragma warning restore CA1031 // Do not catch general exception types
                inprogress = false;
            }, null, 5000, 5000);

            return(true);
        }
Esempio n. 2
0
        public Tests()
        {
            server = new HTTPRPCServer("localhost", 5010);

            server.Run();

            cli     = HTTPRPCClient.Client <IHttpAPIGet>(new Uri("http://localhost:5010/api"));
            cliPost = HTTPRPCClient.Client <IHttpAPIPost>(new Uri("http://localhost:5010/api"));
        }
Esempio n. 3
0
 public void TestCommunicationError()
 {
     try
     {
         var lcli = HTTPRPCClient.Client <IHttpAPIGet>(new Uri("http://fakehostfortest:9999"));
         var r    = lcli.IntResult();
         throw new Exception("Not generated exception at communication fault");
     }
     catch (Exception)
     {
     }
 }