Esempio n. 1
0
        static void Main(string[] args)
        {
            const int port      = 50052;
            var       pubsubImp = new PubSubImpl();

            Grpc.Core.Server server = new Grpc.Core.Server
            {
                Services = { PubSub.BindService(pubsubImp) },
                Ports    = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("RouteGuide server listening on port " + port);
            Console.WriteLine("Insert event. 'q' to quit.");
            string input;

            while ((input = Console.ReadLine()) != "q")
            {
                pubsubImp.Publish(input);
            }

            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Environment.SetEnvironmentVariable("GRPC_TRACE", "tcp,channel,http,secure_endpoint");
            Environment.SetEnvironmentVariable("GRPC_VERBOSITY", "DEBUG");

            //List<ChannelOption> channelOptions = new List<ChannelOption>();
            //channelOptions.Add(new ChannelOption("grpc.http2.min_ping_interval_without_data_ms", 1000));
            //channelOptions.Add(new ChannelOption("grpc.http2.max_pings_without_data", 0));
            //channelOptions.Add(new ChannelOption("grpc.keepalive_permit_without_calls", 1));
            //channelOptions.Add(new ChannelOption("grpc.keepalive_time_ms", 10 * 1000));

            const int port      = 50052;
            var       pubsubImp = new PubSubImpl();

            Grpc.Core.Server server = new Grpc.Core.Server(/*channelOptions*/)
            {
                Services = { PubSub.BindService(pubsubImp) },
                Ports    = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("RouteGuide server listening on port " + port);
            Console.WriteLine("Insert event. 'q' to quit.");
            string input;

            while ((input = Console.ReadLine()) != "q")
            {
                pubsubImp.Publish(input);
            }

            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }