void ButtonConnectClick(object sender, EventArgs e) { string api_host = textBox_host.Text; string api_token = textBox_token.Text; int api_port = 22800; if (!Int32.TryParse(textBox_port.Text, out api_port)) { printToLog("Failed to parse port, using default value: " + 22800); } printToLog("attempt to connect to the Utopia client.."); try { client = new UtopiaLib.Client(api_host, api_port, api_token); if (client.checkClientConnection()) { printToLog("successful connection!"); printToLog("loading a list of crypto cards.."); updateCardsList(); } else { printToLog("failed to connect to client"); } } catch (Exception ex) { printToLog("catched exception: " + ex.Message); } }
void Btn_connectClick(object sender, EventArgs e) { if (is_connected) { DialogResult result = MessageBox.Show("Close current connection and open new?\nCurrent processes will be canceled", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); switch (result) { case DialogResult.Yes: appendLog("I create a new connection to the client"); resumeForm(); break; case DialogResult.No: return; } } int port = 22160; Int32.TryParse(input_port.Text, out port); appendLog("I'm trying to connect to a client..."); try { client = new UtopiaLib.Client(input_host.Text, port, input_token.Text); decimal balance = client.getBalance(); appendLog("Success!"); appendLog("Available balance: " + balance.ToString() + " CRP"); is_connected = true; } catch (Exception ex) { appendLog("Failed to connect: " + ex.Message); is_connected = false; } //renderVoucher("test"); }