Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddScoped <TeacherService>();

            const int Port = 50012;

            Server server = new Server
            {
                Services = { TeacherRpcService.BindService(new TeacherService()) },
                Ports    = { new ServerPort("192.168.1.78", Port, ServerCredentials.Insecure) }
            };

            server.Start();
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            const int Port = 50012;

            Server server = new Server
            {
                Services = { TeacherRpcService.BindService(new TeacherService()) },
                Ports    = { new ServerPort("192.168.1.78", Port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("grpc server listening on port " + Port);
            Console.WriteLine("Press any key to stop server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }