public FSSetupPage() { InitializeComponent(); this.Hide(); niServer.Visible = true; WindowState = FormWindowState.Minimized; tbIPAddress.Text = TCPFunctions.get_IP_address(); bInFlight = false; connectionTimer = new Timer(); connectionTimer.Interval = 5000; connectionTimer.Tick += new EventHandler(OnConnectionTimerElapsed); connectionTimer.Start(); hostPortNum = (int)Properties.Settings.Default["hostPortNumber"]; fsType = (FlightSimType)((int)Properties.Settings.Default["FSTypeDefault"]); if (fsType == FlightSimType.FST_FSX) { mnuFSX.Checked = true; mnuP3D.Checked = false; } else if (fsType == FlightSimType.FST_P3D) { mnuFSX.Checked = false; mnuP3D.Checked = true; } tbPortNum.Text = hostPortNum.ToString(); StartListener(); }
// --------------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------- Client Part -------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------------- private void StartListener() { FSRemoteServer = new TCPServer(IPAddress.Parse(TCPFunctions.get_IP_address()), hostPortNum, 0); FSRemoteServer.ClientConnectionEstablished += new ConnectionEventHandler(updateClientConnectionState); FSRemoteServer.DataTransmissionRecieved += new DataRecieved(handleClientDataRecieved); FSRemoteServer.OnError += new ErrorHandler(OnServerConnectionError); try { FSRemoteServer.asyncInit(); } catch { System.Windows.MessageBox.Show("Couldn't find network."); return; } }