bool connect(string host = "127.0.0.1", string token = "", int port = 20000)
    {
        //endpoint = protocol + "://" + host + port.ToString() + "/api/" + api_version;
        api_host = protocol + "://" + host;

        client = new UtopiaLib.Client(api_host, port, token);
        //client.api_version = api_version;
        return(client.checkClientConnection());
    }
Esempio n. 2
0
    bool auth()
    {
        try {
            client = new UtopiaLib.Client(api_host, api_port, api_token);
        } catch (UtopiaLib.ApiErrorException apiex) {
            last_error = "api error: " + apiex.Message;
            return(false);
        } catch (SocketException socketex) {
            //TODO: solve problem with socket exception uncaught (wtf??)
            last_error = "socket exception: " + socketex.Message;
            return(false);
        } catch (System.Exception ex) {
            last_error = "catched exception: " + ex.Message;
            return(false);
        }

        return(client.checkClientConnection());
    }
Esempio n. 3
0
        void Btn_connectClick(object sender, EventArgs e)
        {
            loger.print("Trying to connect to the client ..");
            int port = 22648;

            int.TryParse(textBox_port.Text, out port);
            client = new UtopiaLib.Client(textBox2_host.Text, port, textBox_token.Text);

            string result = "";

            try {
                result = JsonConvert.SerializeObject(client.getSystemInfo(), Formatting.Indented);
            } catch (UtopiaLib.ApiErrorException ex) {
                result = "Catched ApiErrorException: " + ex.Message;
            }

            loger.print(result);
        }