Esempio n. 1
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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        /// <summary>
        /// Bi-directional streaming example. Send some chat messages, and print any
        /// chat messages that are sent from the server.
        /// </summary>
        public async Task RouteChat()
        {
            try
            {
                Log("*** RouteChat");
                var requests = new List <RouteNote>
                {
                    NewNote("First message", 0, 0),
                    NewNote("Second message", 0, 1),
                    NewNote("Third message", 1, 0),
                    NewNote("Fourth message", 0, 0)
                };

                using (var call = client.RouteChat())
                {
                    var responseReaderTask = Task.Run(async() =>
                    {
                        while (await call.ResponseStream.MoveNext())
                        {
                            var note = call.ResponseStream.Current;
                            Log("Got message \"{0}\" at {1}, {2}", note.Message,
                                note.Location.Latitude, note.Location.Longitude);
                        }
                    });

                    foreach (RouteNote request in requests)
                    {
                        Log("Sending message \"{0}\" at {1}, {2}", request.Message,
                            request.Location.Latitude, request.Location.Longitude);

                        await call.RequestStream.WriteAsync(request);
                    }
                    await call.RequestStream.CompleteAsync();

                    await responseReaderTask;

                    Log("Finished RouteChat");
                }
            }
            catch (RpcException e)
            {
                Log("RPC failed", e);
                throw;
            }
        }
Esempio n. 4
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();
        }
Esempio n. 5
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();
        }