public DaemonCenterServerRpcHttpHost(Server daemonCenterServer)
        {
            try
            {
                // Start Log Server
                string certVaultDir = Lfs.ConfigPathStringToPhysicalDirectoryPath(@"Local/DaemonCenterRpc_CertVault/");

                this.CertVault = new CertVault(certVaultDir,
                                               new CertVaultSettings(EnsureSpecial.Yes)
                {
                    ReloadIntervalMsecs = 3600 * 1000,
                    UseAcme             = false,
                    NonAcmeEnableAutoGenerateSubjectNameCert = false,
                });

                PalSslServerAuthenticationOptions sslOptions = new PalSslServerAuthenticationOptions(this.CertVault.X509CertificateSelector("dummy", true), true, null);

                this.DaemonCenterServer = daemonCenterServer;

                JsonRpcServerConfig rpcCfg = new JsonRpcServerConfig();

                HttpServerOptions httpConfig = new HttpServerOptions
                {
                    HttpPortsList  = new List <int>(),
                    HttpsPortsList = Consts.Ports.DaemonCenterHttps._SingleList(),
                    UseStaticFiles = false,
                    AutomaticRedirectToHttpsIfPossible = false,
                    HiveName           = "DaemonCenterRpcHttpServer",
                    DenyRobots         = true,
                    UseGlobalCertVault = false,
                    ServerCertSelector = (param, sni) => (X509Certificate2)(this.CertVault.X509CertificateSelector(sni, true).NativeCertificate),
                };

                this.HttpServer = JsonRpcHttpServerBuilder.StartServer(httpConfig, rpcCfg, this.DaemonCenterServer);
            }
            catch
            {
                this._DisposeSafe();
                throw;
            }
        }
 public static HttpServer <JsonRpcHttpServerBuilder> StartServer(HttpServerOptions httpCfg, JsonRpcServerConfig rpcServerCfg, JsonRpcServerApi rpcApi, CancellationToken cancel = default)
 => new HttpServer <JsonRpcHttpServerBuilder>(httpCfg, (rpcServerCfg, rpcApi), cancel);
        public static void jsonrpc_client_server_both_test()
        {
            //jsonrpc_server_invoke_test().Wait();return;

            // start server
            HttpServerOptions http_cfg = new HttpServerOptions()
            {
                DebugKestrelToConsole = false,
            };
            JsonRpcServerConfig rpc_cfg = new JsonRpcServerConfig()
            {
            };

            using (RpcServerApiTest h = new RpcServerApiTest())
                using (var s = JsonRpcHttpServerBuilder.StartServer(http_cfg, rpc_cfg, h))
                {
                    Ref <bool> client_stop_flag = new Ref <bool>();

                    // start client
                    ThreadObj client_thread = ThreadObj.Start(param =>
                    {
                        //Kernel.SleepThread(-1);

                        //using ()
                        {
                            //c.AddHeader("X-1", "Hello");

                            rpctmp1 t = new rpctmp1();
                            t.a       = new rpc_t()
                            {
                                Int1 = 2,
                                Str1 = "Neko",
                            };

                            //JsonRpcResponse<object> ret = c.CallOne<object>("Test1", t).Result;
                            //JsonRpcResponse<object> ret = c.CallOne<object>("Test2", t).Result;

                            Benchmark b = new Benchmark("rpccall");

                            JsonRpcHttpClient <rpc_server_api_interface_test> c = new JsonRpcHttpClient <rpc_server_api_interface_test>("http://127.0.0.1:88/rpc");
                            var threads = ThreadObj.StartMany(256, par =>
                            {
                                while (client_stop_flag.Value == false)
                                {
                                    //c.Call.Divide(8, 2).Wait();
                                    TMP1 a = new TMP1()
                                    {
                                        a = 4, b = 2
                                    };
                                    c.MT_Call <object>("Divide", a, true)._GetResult();
                                    //c.ST_CallOne<object>("Divide", a, true).Wait();
                                    b.IncrementMe++;
                                }
                            }
                                                              );

                            foreach (var thread in threads)
                            {
                                thread.WaitForEnd();
                            }

                            //c.Call.Divide(8, 2).Result.Print();
                            //c.Call.Divide(8, 2).Result.Print();
                            //c.Call.Test3(1, 2, 3).Result.Print();
                            //c.Call.Test5(1, "2").Result.ObjectToJson().Print();
                            //var fnlist = c.Call.Test6().Result;
                            ////foreach (var fn in fnlist) fn.Print();
                            //c.Call.Test7(fnlist).Result.Print();

                            //Con.WriteLine(ret.ObjectToJson());
                        }
                    }, null);

                    Con.ReadLine("Enter to quit>");

                    client_stop_flag.Set(true);

                    client_thread.WaitForEnd();
                }
        }
        public EasyJsonRpcServer(HttpServerOptions httpConfig, CancellationToken cancel = default) : base(cancel)
        {
            JsonRpcServerConfig rpcCfg = new JsonRpcServerConfig();

            this.HttpServer = JsonRpcHttpServerBuilder.StartServer(httpConfig, rpcCfg, this, cancel);
        }