static void Main() { /*Application.SetHighDpiMode(HighDpiMode.SystemAware); * Application.EnableVisualStyles(); * Application.SetCompatibleTextRenderingDefault(false); * Application.Run(new Form1());*/ VRClient client = new VRClient("145.48.6.10", 6666); if (client.Connect()) { List <DVRSessionItem> sessionList = client.GetSessionList(); for (int i = 0; i < sessionList.Count; i++) { Console.WriteLine($"{i + 1} {sessionList[i].clientinfo.user}"); } Console.Write("Select Session: "); int selectedSession; while (!int.TryParse(Console.ReadLine(), out selectedSession)) { Console.Write("Select Session: "); } Console.Write("Enter key (leave empty if not needed): "); string key = Console.ReadLine(); try { VRTunnel tunnel = client.CreateTunnel(sessionList[selectedSession - 1].id, key); if (tunnel != null) { bool succeded = false; while (!succeded) { try { succeded = SetScene(tunnel); } catch (VRCallbackException ex) { Console.WriteLine($"Error package: {ex.Message}"); } } } } catch (VRClientException ex) { Console.WriteLine($"Create Tunnel failed: {ex.Message}"); } } else { Console.WriteLine("Connection Failed!"); } }
private void ConnectButton_Click(object sender, EventArgs e) { if (vrClient.IsConnected) { try { if (this.tunnel == null) { MessageBox.Show("Press \"OK\" to set up the VR scene...", "VR scene init"); this.tunnel = vrClient.CreateTunnel(this.sessionList[dataGridView1.CurrentRow.Index].id, keyTextBox.Text); } if (tunnel != null) { bool succeded = false; while (!succeded) { try { succeded = SetScene(this.tunnel); } catch (VRCallbackException ex) { Console.WriteLine($"Error package: {ex.Message}"); } } MainForm mainForm = new MainForm(this.client, this.tunnel); mainForm.Show(); this.isDisconnecting = true; this.Close(); } } catch (VRClientException ex) { keyTextBox.Text = ""; MessageBox.Show("Something went wrong! Please enter a valid key, and press \"Connect\"", "Error"); Console.WriteLine($"Create Tunnel failed: {ex.Message}"); } } else { Console.WriteLine("Connection Failed!"); } }