private void btnStopServer_Click(object sender, EventArgs e) { if (MainServer.Active) { lbConnectedClients.Items.Clear(); MainServer.Stop(); GetDataLoop.Stop(); lblStatus.ForeColor = Color.Red; lblStatus.Text = "Offline"; MessageBox.Show("Server stopped.", "Server Stopped", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnStartServer_Click(object sender, EventArgs e) { if (!MainServer.Active) { try { int Port = Settings.GetPort(); MainServer.Start(Port); lblStatus.ForeColor = Color.Green; lblStatus.Text = "Online"; GetDataLoop.Start(); MessageBox.Show("Server started on port " + Port + ".", "Server Started", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception EX) { MessageBox.Show("Error: " + EX.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }