예제 #1
0
        static void Main(string[] args)
        {
            const int Port = 50052;
            const int MaxMessageLengthBytes = Int32.MaxValue;

            var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);

            ChannelOption maxReceiveMessageLength = new ChannelOption(ChannelOptions.MaxMessageLength, MaxMessageLengthBytes);

            //ChannelOption maxSendMessageLength = new ChannelOption(ChannelOptions.MaxMessageLength, MaxMessageLengthBytes);
            ChannelOption[] grpcChannelOptions = { maxReceiveMessageLength };

            Server server = new Server(grpcChannelOptions)
                            //Server server = new Server()
            {
                Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
                Ports    = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };

            server.Start();

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

            server.ShutdownAsync().Wait();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            const int Port = 50052;

            var    features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
            Server server   = new Server
            {
                Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
                Ports    = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };

            server.Start();
            Console.WriteLine("RouteGuide server listening on port " + Port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();
            server.ShutdownAsync().Wait();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
            var client  = new RouteGuideClient(RouteGuide.NewClient(channel));

            // Looking for a valid feature
            client.GetFeature(409146138, -746188906);

            // Feature missing.
            client.GetFeature(0, 0);

            // Looking for features between 40, -75 and 42, -73.
            client.ListFeatures(400000000, -750000000, 420000000, -730000000).Wait();

            // Record a few randomly selected points from the features file.
            client.RecordRoute(RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile), 10).Wait();

            // Send and receive some notes.
            client.RouteChat().Wait();

            channel.ShutdownAsync().Wait();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
예제 #4
0
파일: Program.cs 프로젝트: rwightman/grpc
 public RouteGuideClient(RouteGuide.IRouteGuideClient client)
 {
     this.client = client;
 }