コード例 #1
0
        static void Main(string[] args)
        {
            var server = new RpcServer("127.0.0.1", 12345)
                         .Map <IHelloService, HelloService>();

            Console.WriteLine("开始接收请求...");
            server.Run();
        }
コード例 #2
0
ファイル: ServerTests.cs プロジェクト: apkbox/closetrpc
        public void Test1()
        {
            var server = new RpcServer(new FakeServerTransport());
            var task   = new Task(() => server.Run());

            task.Start();
            Thread.Sleep(1000);
            server.Shutdown(false);
        }
コード例 #3
0
        private static void ServerThread()
        {
            var transport = new SocketServerTransport(4242);
            var server    = new RpcServer(transport);

            Program.serverInstance = server;
            var service = new SettingsService(server.EventSource);

            server.RegisterService(service);
            server.Run();
            service.Dispose();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            AppSeed.Instance.InitConfig();
            RpcServer rpcServer       = new RpcServer();
            var       rpcServerConfig = ConfigHelper.Instance.GetComponentConfig();

            if ((rpcServerConfig == null) || (rpcServerConfig.ServiceConfig == null))
            {
                Console.WriteLine("RPC服务端未配置");
            }
            else
            {
                rpcServer.Run(rpcServerConfig.ServiceConfig);
            }
        }
コード例 #5
0
ファイル: RpcTest.cs プロジェクト: DeemDream/SimCivil
        public ServerFixture()
        {
            var builder = new ContainerBuilder();

            builder.UseRpcSession();
            builder.RegisterRpcProvider <TestServiceA, ITestServiceA>().InstancePerChannel();
            builder.RegisterRpcProvider <TestServiceB, ITestServiceB>().SingleInstance();

            Server = new RpcServer(builder.Build())
            {
                Debug = true
            };
            Server.Bind(9999);
            Server.Run().Wait();
        }
コード例 #6
0
        public ServerFixture()
        {
            var services = new ServiceCollection();

            services.AddLogging(lb => {
                lb.AddConsole();
            });

            var builder = new ContainerBuilder();

            builder.Populate(services);
            builder.UseRpcSession();
            builder.RegisterRpcProvider <TestServiceA, ITestServiceA>().InstancePerChannel();
            builder.RegisterRpcProvider <TestServiceB, ITestServiceB>().SingleInstance();

            var container = builder.Build();

            Server = new RpcServer(container)
            {
                Debug = true
            };
            Server.Bind(9999);
            Server.Run().Wait();
        }