@@ -141,10 +141,9 @@ namespace GrpcGreeterClient
141141 {
142142 static async Task Main (string [] args )
143143 {
144- var httpClient = new HttpClient ();
145144 // The port number(5001) must match the port of the gRPC server.
146- httpClient . BaseAddress = new Uri (" https://localhost:5001" );
147- var client = GrpcClient . Create < Greeter .GreeterClient >( httpClient );
145+ var channel = GrpcChannel . ForAddress (" https://localhost:5001" );
146+ var client = new Greeter .GreeterClient ( channel );
148147 var reply = await client .SayHelloAsync (
149148 new HelloRequest { Name = " GreeterClient" });
150149 Console .WriteLine (" Greeting: " + reply .Message );
@@ -159,40 +158,8 @@ namespace GrpcGreeterClient
159158
160159The Greeter client is created by:
161160
162- * Instantiating an ` HttpClient ` containing the information for creating the connection to the gRPC service.
163- * Using the ` HttpClient ` to construct the Greeter client:
164-
165- ``` csharp
166- static async Task Main (string [] args )
167- {
168- var httpClient = new HttpClient ();
169- // The port number(5001) must match the port of the gRPC server.
170- httpClient .BaseAddress = new Uri (" https://localhost:5001" );
171- var client = GrpcClient .Create <Greeter .GreeterClient >(httpClient );
172- var reply = await client .SayHelloAsync (
173- new HelloRequest { Name = " GreeterClient" });
174- Console .WriteLine (" Greeting: " + reply .Message );
175- Console .WriteLine (" Press any key to exit..." );
176- Console .ReadKey ();
177- }
178- ```
179-
180- The Greeter client calls the asynchronous ` SayHello ` method. The result of the ` SayHello ` call is displayed:
181-
182- ``` csharp
183- static async Task Main (string [] args )
184- {
185- var httpClient = new HttpClient ();
186- // The port number(5001) must match the port of the gRPC server.
187- httpClient .BaseAddress = new Uri (" https://localhost:5001" );
188- var client = GrpcClient .Create <Greeter .GreeterClient >(httpClient );
189- var reply = await client .SayHelloAsync (
190- new HelloRequest { Name = " GreeterClient" });
191- Console .WriteLine (" Greeting: " + reply .Message );
192- Console .WriteLine (" Press any key to exit..." );
193- Console .ReadKey ();
194- }
195- ```
161+ * Instantiating a ` GrpcChannel ` containing the information for creating the connection to the gRPC service.
162+ * Using the ` GrpcChannel ` to construct the Greeter client.
196163
197164## Test the gRPC client with the gRPC Greeter service
198165
0 commit comments