示例#1
0
        public JsonResult GetBooks(int offset, int limit)
        {
            using (var _client = new BookService.BookServiceClient())
            {
                var books = _client.GetAllBooks();

                return(Json(new { books = books }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        static async Task Main(string[] args)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);

            var channel = GrpcChannel.ForAddress("https://localhost:32794");
            var client  = new BookService.BookServiceClient(channel);

            using var call = client.GetAllBooks(new AllBooksRequest()
            {
                ItemsPerPage = 1
            });
            while (await call.ResponseStream.MoveNext())
            {
                Console.Write(Environment.NewLine);
                Console.Write(call.ResponseStream.Current.Books);
            }

            Console.ReadKey();
        }