@@ -53,16 +53,15 @@ static async Task Main(string[] args)
53
53
var client = provider.GetRequiredService<CountryServiceClient>();
54
54
*/
55
55
56
-
57
56
// gRPC-Web
58
- var handler = new GrpcWebHandler ( GrpcWebMode . GrpcWebText , HttpVersion . Version11 , new HttpClientHandler ( ) ) ;
59
- var channel = GrpcChannel . ForAddress ( "https://grpcwebdemo.azurewebsites.net" , new GrpcChannelOptions
60
- {
61
- HttpClient = new HttpClient ( handler ) ,
62
- LoggerFactory = loggerFactory
63
- } ) ;
64
- var clientWeb = new CountryServiceClient ( channel ) ;
65
-
57
+ // var handler = new GrpcWebHandler(GrpcWebMode.GrpcWebText, HttpVersion.Version11, new HttpClientHandler());
58
+ // var channel = GrpcChannel.ForAddress("https://grpcwebdemo.azurewebsites.net:8080 ", new GrpcChannelOptions
59
+ // {
60
+ // HttpClient = new HttpClient(handler),
61
+ // LoggerFactory = loggerFactory
62
+ // });
63
+ // var clientWeb = new CountryServiceClient(channel);
64
+
66
65
try
67
66
{
68
67
/*
@@ -116,18 +115,29 @@ static async Task Main(string[] args)
116
115
countries.ForEach(x => Console.WriteLine($"Found country {x.CountryName} ({x.CountryId}) {x.Description}"));
117
116
*/
118
117
119
-
118
+
120
119
// Get all gRPC-web
121
- var countriesweb = ( await clientWeb . GetAllAsync ( new EmptyRequest ( ) ) ) . Countries . Select ( x => new Country
120
+ //var countriesweb = (await clientWeb.GetAllAsync(new EmptyRequest())).Countries.Select(x => new Country
121
+ //{
122
+ // CountryId = x.Id,
123
+ // Description = x.Description,
124
+ // CountryName = x.Name
125
+ //}).ToList();
126
+
127
+ //Console.WriteLine("Found countries with gRPC-Web");
128
+ //countriesweb.ForEach(x => Console.WriteLine($"Found country with gRPC-Web: {x.CountryName} ({x.CountryId}) {x.Description}"));
129
+
130
+
131
+ var handler2 = new GrpcWebHandler ( GrpcWebMode . GrpcWebText , new HttpClientHandler ( ) ) ;
132
+ var channel2 = GrpcChannel . ForAddress ( "https://grpcweb.azurewebsites.net" , new GrpcChannelOptions
122
133
{
123
- CountryId = x . Id ,
124
- Description = x . Description ,
125
- CountryName = x . Name
126
- } ) . ToList ( ) ;
134
+ HttpClient = new HttpClient ( handler2 ) ,
135
+ LoggerFactory = loggerFactory
136
+ } ) ;
137
+ var clientweb2 = new Greeter . GreeterClient ( channel2 ) ;
138
+ var response = await clientweb2 . SayHelloAsync ( new HelloRequest { Name = ".NET" } ) ;
127
139
128
- Console . WriteLine ( "Found countries with gRPC-Web" ) ;
129
- countriesweb . ForEach ( x => Console . WriteLine ( $ "Found country with gRPC-Web: { x . CountryName } ({ x . CountryId } ) { x . Description } ") ) ;
130
-
140
+ Console . WriteLine ( response . Message ) ;
131
141
132
142
}
133
143
catch ( RpcException e )
0 commit comments