static void Main(string[] args) { var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure); var client = new RouteGuideClient( // Use Application Insights new RouteGuide.RouteGuideClient(channel.UseApplicationInsights())); // 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(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); channel.ShutdownAsync().Wait(); }
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"); }
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(); }
/// <summary> /// Server-streaming example. Calls listFeatures with a rectangle of interest. Prints each response feature as it arrives. /// </summary> public async Task ListFeatures(int lowLat, int lowLon, int hiLat, int hiLon) { try { Log("*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}", lowLat, lowLon, hiLat, hiLon); Rectangle request = new Rectangle { Lo = new Point { Latitude = lowLat, Longitude = lowLon }, Hi = new Point { Latitude = hiLat, Longitude = hiLon } }; using (var call = client.ListFeatures(request)) { var responseStream = call.ResponseStream; StringBuilder responseLog = new StringBuilder("Result: "); while (await responseStream.MoveNext()) { Feature feature = responseStream.Current; responseLog.Append(feature.ToString()); } Log(responseLog.ToString()); } } catch (RpcException e) { Log("RPC failed " + e); throw; } }
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(); }
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(); }