-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram_reference.cs
More file actions
30 lines (26 loc) · 1.03 KB
/
Program_reference.cs
File metadata and controls
30 lines (26 loc) · 1.03 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
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Grpc.Net.Client;
namespace Calc
{
class Program
{
static void Main(string[] args)
{
var x = int.Parse(args[0]);
var y = int.Parse(args[1]);
// Création du client (nous devons accepter )
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
using var channel = GrpcChannel.ForAddress("http://localhost:50051");
var client = new Calc.CalcClient(channel);
// Appels au serveur
var replyAdd = client.Add(new ArithmeticRequest { A = x, B = y });
var replyMultiply = client.Multiply(new ArithmeticRequest { A = x, B = y });
// Affichage des résultats
Console.WriteLine($"Client .NET pour Calc");
Console.WriteLine($"{x} + {y} = {replyAdd.Result}");
Console.WriteLine($"{x} * {y} = {replyMultiply.Result}");
}
}
}