public ServerConfigDialog() { InitializeComponent(); ServerOptions.ReadFile(); hostnameTextBox.Text = System.Net.Dns.GetHostName(); portTextBox.Text = ServerOptions.PortNumber.ToString(); }
public Form1() { string errorMsg = string.Empty; int seats = -1; if (Environment.GetCommandLineArgs().Length > 1) { ServerOptions.ReadFile(); String portString = Environment.GetCommandLineArgs()[1]; ServerOptions.PortNumber = Int32.Parse(portString); ServerOptions.WriteFile(); } else { ServerConfigDialog d = new ServerConfigDialog(); d.DialogMessage = "Configure the server port:"; if (d.ShowDialog(this) == DialogResult.Cancel) { MessageBox.Show(this, "Closing DDD", "User Requested Shutdown", MessageBoxButtons.OK); this.Close(); return; } while (!SimCoreServer.SimCoreServer.CheckNetworkSettings()) { d.DialogMessage = "The specified port is not available.\nPlease shutdown any other application\nusing the port or choose a different one."; d.ShowDialog(this); } } InitializeComponent(); server = new SimCoreServer.SimCoreServer(); LoadServerOptions(); eventClient = new SimulationEventDistributorClient(); SimCoreServer.SimCoreServer.simEngine.simCore.distributor.RegisterClient(ref eventClient); eventClient.Subscribe("ServerState"); eventClient.Subscribe("PauseScenario"); eventClient.Subscribe("ResumeScenario"); serverState = "SCENARIO_STOPPED"; comboBoxReplaySpeed.SelectedIndex = 4; comboBoxReplaySpeed.Enabled = false; toolStripStatusLabelServerStatus.Text = "Server: STOPPED"; toolStripStatusLabelSimStatus.Text = "Simulation: STOPPED"; DMInfo = new DMInfoManager(this); UpdateScenarioNameLabel(); updateTimer.Start(); UpdateVoiceServerButton(); }
public SimCoreServer() { ServerOptions.ReadFile(); WriteClientAppConfig(); simEngine.Initialize(ServerOptions.SimulationModelPath, ServerOptions.PortNumber); simEngine.StartSimCore(); simEngine.StartViewManager(); eventClient = new SimulationEventDistributorClient(); simEngine.simCore.distributor.RegisterClient(ref eventClient); eventClient.Subscribe("PauseScenarioRequest"); eventClient.Subscribe("ResumeScenarioRequest"); eventClient.Subscribe("LoadScenarioRequest"); eventClient.Subscribe("StopScenarioRequest"); eventClient.Subscribe("SimCoreReady"); eventClient.Subscribe("ForkReplayStarted"); eventClient.Subscribe("ForkReplayFinished"); eventClient.Subscribe("GameSpeedRequest"); //AD: UN-Removed for now }
public static bool CheckNetworkSettings() { IPAddress ip; ServerOptions.ReadFile(); TcpListener testServer = NetworkUtility.GetTcpListener(System.Net.Dns.GetHostName(), ServerOptions.PortNumber, out ip); try { testServer.Start(); testServer.Stop(); return(true); } catch { return(false); } }