Exemplo n.º 1
0
        public static async Task StartServer(string host, int port)
        {
            var interceptor = new ServerCallInterceptor();

            _server = new Server
            {
                Services =
                {
                    RpcCategoryService.BindService(new CategoryService()).Intercept(interceptor),
                    RpcCommonService.BindService(new CommonService()).Intercept(interceptor),
                    RpcDashboardService.BindService(new DashboardService()).Intercept(interceptor),
                    RpcDetailService.BindService(new DetailService()).Intercept(interceptor),
                    RpcMainService.BindService(new MainService()).Intercept(interceptor),
                    RpcReviewService.BindService(new ReviewService()).Intercept(interceptor)
                },
                Ports =
                {
                    new ServerPort(host, port, ServerCredentials.Insecure)
                }
            };

            _server.Start();

#if FAKE
            Log.Information("It's fake time!");
            await TimeCatDB.Instance.Initialize(Environment.Database);

            await Dummies.Create();

            Log.Information("Fake DB prepare got succeed");
#endif
            Log.Information("Listening on {Host}:{Port}", host, port);
        }
Exemplo n.º 2
0
        static void StartServer(string host, int port)
        {
            var credentials = new SslServerCredentials(new List <KeyCertificatePair>
            {
                new KeyCertificatePair(
                    ResourceManager.GetText("Certificates.timecat.crt"),
                    ResourceManager.GetText("Certificates.timecat.key")
                    )
            });

            _server = new Server
            {
                Services =
                {
                    RpcCategoryService.BindService(new CategoryService()),
                    RpcCommonService.BindService(new CommonService()),
                    RpcDashboardService.BindService(new DashboardService()),
                    RpcDetailService.BindService(new DetailService()),
                    RpcMainService.BindService(new MainService()),
                    RpcReviewService.BindService(new ReviewService())
                },
                Ports =
                {
                    new ServerPort(host, port, credentials)
                }
            };

            _server.Start();
            Console.WriteLine($"Listening on {host}:{port}");
        }