public ClientForm() { _clientManager = new ClientManager(); InitializeComponent(); ResetUiDisconnected(); InitListView(); //_clientManager.Storage = new ClientStorage(); var thread = new Thread(UpdateServerList); thread.Start(); }
private void PerformTest(int numOfLoadTestClients) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.Invoke(new Action(ResetUiLoadTestOn)); testing = true; for (int i = 0; i < numOfLoadTestClients; i++) { var cM = new ClientManager(); string host = @"127.0.0.1"; int port = 5000; string clientId = "testClient"+i; int timeout = 2; this.Invoke(new Action(() => { host = connectionAddressTextBox.Text.Trim(); port = int.Parse(connectionPortTextBox.Text.Trim()); timeout = int.Parse(connectionTimeoutTextBox.Text.Trim()); })); cM.Init( host, port, clientId, timeout, this, true); testClients.GetOrAdd(i, cM); Thread.Sleep(MQTTBase.THREAD_SLEEP_REST_TIME); } // wait a bit Thread.Sleep(500); for (int i = 0; i < numOfLoadTestClients; i++) { ClientManager manager; if (testClients.TryGetValue(i, out manager)) { manager.Disconnect(true); } } stopwatch.Stop(); MessageBox.Show(String.Format("Load test completed in {0}ms with {1} clients", stopwatch.ElapsedMilliseconds, numOfLoadTestClients), @"Load test complete!", MessageBoxButtons.OK, MessageBoxIcon.Information); // wait a bit Thread.Sleep(1000); testing = false; Invoke(new Action(ResetUiDisconnected)); }
public SignForm(MainForm f1, ClientManager client) { fmain = f1; currentClient = client; InitializeComponent(); }
private async void _listener_OnKeyPressed(object sender, INPUT e) { bool error = false; string message = ""; try { if (Keyboard.Modifiers == ModifierKeys.Control) { Key k = KeyInterop.KeyFromVirtualKey(e.ki.wVk); int virtualKey = KeyInterop.VirtualKeyFromKey(k); if (k == Key.N) { // Invio della clipboard del client ClientManager.NotifyClipboardAsynch(); } else if (k == Key.M) { // Richiesta della clipboard al server ClipboardTrasfer.SendUpdateRequest(); } else if (virtualKey >= (int)VirtualKeyCode.VK_1 && virtualKey <= (int)VirtualKeyCode.VK_9) // Switch { virtualKey -= (int)VirtualKeyCode.VK_0; if (virtualKey <= listIp.Count) { serverIP = IPAddress.Parse(listIp[virtualKey - 1].ipAddress); Connection.disconnectFromServer(); ConnectWindow c = new ConnectWindow(); c.Show(); } } else if (virtualKey == (int)VirtualKeyCode.VK_0) // Disconnect { MessageDialogResult result = await this.ShowMessageAsync("Exit", "Are you sure you want to disconnect?", MessageDialogStyle.AffirmativeAndNegative, WPFProperties.metroDialogSettings); if (result == MessageDialogResult.Affirmative) { if (disconnectButton.IsEnabled) { Connection.disconnectFromServer(); } } } else { ClientManager.NotifyInputAsynch(e); } } else { ClientManager.NotifyInputAsynch(e); } } catch (Exception ex) { error = true; message = ex.Message; } if (error) { MessageDialogResult result = await this.ShowMessageAsync("Error: " + message, "You are now disconnected from server", MessageDialogStyle.Affirmative, WPFProperties.metroDialogSettings); } }
private static void _listener_KeyUp(object sender, INPUT e) { ClientManager.NotifyInputAsynch(e); }
private static void _mouseListener_MouseEvent(object sender, INPUT e) { ClientManager.NotifyInputAsynch(e); }