예제 #1
0
 private async static void TestStream(string server)
 {
     while (true)
     {
         var channel = new Grpc.Core.Channel(server, ChannelCredentials.Insecure);
         var client  = new RouteGuideClient(channel);
         using (var call = client.ListFeatures(new Rectangle()))
         {
             try
             {
                 while (await call.ResponseStream.MoveNext())
                 {
                     Feature feature = call.ResponseStream.Current;
                     Console.WriteLine($"Received {feature}");
                 }
                 break;
             }
             catch (Exception ex)
             {
                 Console.WriteLine($"{ex.Message}");
                 System.Threading.Thread.Sleep(1000);
                 ; // loop
             }
         }
         channel.ShutdownAsync().Wait();
     }
     Console.WriteLine("Finished TestStream");
 }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
            var client  = new RouteGuideClient(new RouteGuide.RouteGuideClient(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();
        }
예제 #3
0
        static void Main(string[] args)
        {
            GrpcEnvironment.Initialize();

            using (Channel channel = new Channel("127.0.0.1:50052"))
            {
                var client = new RouteGuideClient(RouteGuide.NewStub(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();
            }

            GrpcEnvironment.Shutdown();
        }
예제 #4
0
        static void Main(string[] args)
        {
            int           MaxMessageLengthBytes = Int32.MaxValue;
            ChannelOption maxSendMessageLength  = new ChannelOption(ChannelOptions.MaxMessageLength, MaxMessageLengthBytes);

            ChannelOption[] grpcChannelOptions = { maxSendMessageLength };

            var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure, grpcChannelOptions);
            //var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);

            var client = new RouteGuideClient(new RouteGuide.RouteGuideClient(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();
            ChunReq chunReq = new ChunReq()
            {
                ChunkCounter = 0
            };

            client.GetBytes(chunReq).Wait();
            try
            {
                client.GetAllBytes(chunReq).Wait();
            }
            catch (Exception ex)
            {
            }

            channel.ShutdownAsync().Wait();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
예제 #5
0
        private static void TestNormal(string server)
        {
            var channel = new Grpc.Core.Channel(server, ChannelCredentials.Insecure);
            var client  = new RouteGuideClient(channel);

            // Looking for a valid feature
            var       pt = new Routeguide.Point();
            Stopwatch sw = Stopwatch.StartNew();

            for (int i = 0; i < 20; i++)
            {
                var f = client.GetFeature(pt);
                //Console.WriteLine($"  {f}  {sw.ElapsedMilliseconds}");
            }
            sw.Stop();
            Console.WriteLine($".NET Elapsed {sw.ElapsedMilliseconds}");

            Console.WriteLine("Press any key to exit...");
            channel.ShutdownAsync().Wait();
        }
예제 #6
0
파일: Program.cs 프로젝트: rwightman/grpc
        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();
        }
예제 #7
0
 public Client(RouteGuideClient client)
 {
     this.client = client;
 }
예제 #8
0
        static void Main(string[] args)
        {
            GrpcEnvironment.Initialize();

            using (Channel channel = new Channel("127.0.0.1:50052"))
            {
                var client = new RouteGuideClient(RouteGuide.NewStub(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();
            }

            GrpcEnvironment.Shutdown();
        }