-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
31 lines (27 loc) · 883 Bytes
/
Program.cs
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
using Grpc.Core;
using GrpcGeo.Domain;
using IpGeo;
using System;
using System.Net;
namespace GrpcGeo.Client
{
internal class Program
{
private static void Main(string[] args)
{
Channel channel = new Channel($"127.0.0.1:{Constants.Port}", ChannelCredentials.Insecure);
var client = new IpLocator.IpLocatorClient(channel);
var request = new LocationRequest
{
App = "dotnet core",
Ip = new WebClient().DownloadString("http://ipinfo.io/ip").Replace("\n", "")
};
var reply = client.Find(request);
Console.WriteLine($"The IP '{request.Ip}' comes from {reply.City} in {reply.Country}.");
channel.ShutdownAsync().Wait();
Console.WriteLine($"Press any key to exit...");
Console.ReadKey();
}
}
}