Example #1
0
        public AboutViewModel()
        {
            Console.WriteLine("Start client...");
            string s = GetRootCertificates();

            // ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
            IPAddress   addr  = IPAddress.Parse("192.168.7.7");
            IPHostEntry entry = Dns.GetHostEntry(addr);

            Console.WriteLine(entry.HostName);
            Console.WriteLine("Hello World!");
            var channel = new Channel("192.168.7.7", 5000, new SslCredentials(s));

            client         = new Informer.InformerClient(channel);
            Title          = "About";
            OpenWebCommand = new Command(async() => await Browser.OpenAsync("https://xamarin.com"));
            OnAuth         = new Command(OnAuthCommand);
            OnPing         = new Command(OnPingCommand);
            OnGetInfo      = new Command(OnGetInfoCommand);
        }
Example #2
0
        private async Task GetServerVersion(Informer.InformerClient client, string token)
        {
            Console.WriteLine("Getting information...");
            try
            {
                Metadata headers = null;
                var      _token  = await Authenticate();

                if (_token != null)
                {
                    headers = new Metadata();
                    headers.Add("Authorization", $"Bearer {token}");
                }

                var response = await client.GetServerInformationAsync(new Empty(), headers);

                Console.WriteLine($"Server version: {response.Version}");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error get server version." + Environment.NewLine + ex.ToString());
            }
        }
Example #3
0
        private async Task GetPing(Informer.InformerClient client)
        {
            Console.WriteLine("Getting ping...");
            try
            {
                Metadata headers = null;

                //var response = client.GetServerPing(new Empty(), headers);

                var response = await client.GetServerPingAsync(new Empty(), headers);

                string result = "Nan";
                if (response.PingResponse_ == 1)
                {
                    result = "Ok!";
                }
                Console.WriteLine($"Ping say: {result }");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error get server ping." + Environment.NewLine + ex.ToString());
            }
        }