public static async Task <List <Host> > GetHostsAsync() { AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); using var channel = GrpcChannel.ForAddress(_uri); var client = new HostsManager.HostsManagerClient(channel); var response = await client.GetHostsAsync(new EmptyParams()); var hosts = response.Hosts_.ToList(); await Task.Run(() => { hosts.AsParallel().ForAll(host => { var ping = PingHost(host.Address) ?? 999; host.Ping = ping; }); }); return(hosts); }
public static async Task SetHostAsync(string hostName, string address) { using var channel = GrpcChannel.ForAddress(_uri); var client = new HostsManager.HostsManagerClient(channel); var response = await client.SetHostAsync(new Host { Address = address, Name = hostName }); }