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(); }
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> /// Client-streaming example. Sends numPoints randomly chosen points from features /// with a variable delay in between. Prints the statistics when they are sent from the server. /// </summary> public async Task RecordRoute(List <Feature> features, int numPoints) { try { Log("*** RecordRoute"); using (var call = client.RecordRoute()) { // Send numPoints points randomly selected from the features list. StringBuilder numMsg = new StringBuilder(); Random rand = new Random(); for (int i = 0; i < numPoints; ++i) { int index = rand.Next(features.Count); Point point = features[index].Location; Log("Visiting point {0}, {1}", point.GetLatitude(), point.GetLongitude()); await call.RequestStream.WriteAsync(point); // A bit of delay before sending the next one. await Task.Delay(rand.Next(1000) + 500); } await call.RequestStream.CompleteAsync(); RouteSummary summary = await call.ResponseAsync; Log("Finished trip with {0} points. Passed {1} features. " + "Travelled {2} meters. It took {3} seconds.", summary.PointCount, summary.FeatureCount, summary.Distance, summary.ElapsedTime); Log("Finished RecordRoute"); } } 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(); }