private void btnListen_Click(object sender, EventArgs e) { if (this.btnListen.Text == "Stop") { this.server.Stop(); this.server = null; this.broadcast.Cancel(); this.broadcast = null; this.btnListen.Text = "Listen"; } else { IPAddress address; try { address = IPAddress.Parse(this.cmbAddresses.Text); } catch { MessageBox.Show("IP Address you entered is invalid, Please try again.", "Invalid IP Address", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.server = new ServerConnection(this, txtUserName.Text, new IPEndPoint(address, Global.PORT)); this.server.LocalUserName = this.txtUserName.Text; this.server.ConnectionAccepted += Server_ConnectionAccepted; server.Start(); this.broadcast = new UdpBroadcast(); this.broadcast.Start(address); this.btnListen.Text = "Stop"; } }
public Core() { _game = new Game(); _serverInfo = new ServerInfo(); _dataPackageProvider = new ServerDataPackageProvider(_serverInfo, _game); _udpserver = new UdpBroadcast(_serverInfo); _connectionHandler = new ClientConnection(_serverInfo, _dataPackageProvider); _disconnectionHandler = new ClientDisconnection(_game, _serverInfo, _dataPackageProvider); _actionsHandler = new ServerActions(_serverInfo, _game, _disconnectionHandler, _dataPackageProvider); _stateMachine = new StateMachine(_serverInfo, _actionsHandler, _game); _validationSystem = new ValidationSystem(_serverInfo, _disconnectionHandler, _connectionHandler, _dataPackageProvider, _actionsHandler); _server = new Server(_actionsHandler, _serverInfo, _stateMachine, _validationSystem, _disconnectionHandler); }
void Start() { _sensors = new Dictionary<string, Sensor> (); _humans = new Dictionary<int, Human> (); _deadHumans = new List<Human> (); _humansToKill = new List<Human> (); _calibrationStatus = CalibrationProcess.FindCenter; _udpBroadcast = new UdpBroadcast (TrackerProperties.Instance.broadcastPort); _loadConfig (); _loadSavedSensors (); }