private void timer1_Tick(object sender, EventArgs e) { _timerticks++; TimerBox.Text = _timerticks.ToString(); Server = FgfsServer.GetInstance(); if (Server.Status == 2) { // thread exited if (Is_Server_Running()) { Console.WriteLine("Stopping server, on timer tick..."); Stop_Server(); } } // TimeBox.Text = DateTime.Now.ToShortTimeString(); TimeBox.Text = DateTime.Now.ToLongTimeString(); }
private void Start_Server() { ChoosePortLabel.Visible = false; string ip = IpComboBox.SelectedItem.ToString(); int port = Convert.ToInt32(PortBox.Text); Server = FgfsServer.GetInstance(); Server.StartServer(ip, port, DataHelper); #if USING_MS_SAPI if (Wants_Speech()) { string speechOut = string.Format("Server I.P. is {0}, on Port {1}", ip, port); this.ms_Voice.Speak(speechOut, SpFlags); //this._speechObj.Speak(speechOut, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault); //this._speechObj.WaitUntilDone(5000000); } #endif //this._startBtn.Enabled = false; this._startBtn.Text = "Stop Server"; _timerticks = 0; // restart the seconds counter _messagecount = 0; }
private void Stop_Server() { string msg = "Stopping server."; #if USING_MS_SAPI if (Wants_Speech()) ms_Voice.Speak(msg, SpFlags); #endif Console.WriteLine(msg); Server = FgfsServer.GetInstance(); Server.SuspendServer(); this._startBtn.Text = "Start Server"; ChoosePortLabel.Visible = true; _timerticks = 0; // restart the seconds counter _messagecount = 0; }
public static FgfsServer GetInstance() { if (_uniqueServer == null) { _uniqueServer = new FgfsServer(); } return _uniqueServer; }