-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (32 loc) · 1.41 KB
/
Program.cs
File metadata and controls
37 lines (32 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Grpc.Net.Client;
using System.Runtime.InteropServices;
namespace GrpcAuthorClient
{
class Program
{
static async Task Main(string[] args)
{
var serverAddress = "https://localhost:5001";
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
// The following statement allows you to call insecure services. To be used only in development environments.
AppContext.SetSwitch(
"System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
serverAddress = "http://localhost:5000";
}
using var channel = GrpcChannel.ForAddress(serverAddress);
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(
new HelloRequest { Name = "GreeterClient from Peter" });
Console.WriteLine("Greeting: " + reply.Message);
var client2 = new Author.AuthorClient(channel);
var reply2 = await client2.GetAuthorAsync(
new AuthorRequest { Name = "Antonio Gonzalez" });
Console.WriteLine("Author: " + reply2.ToString());
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}