public tet_network_c(mainWindow mainWindow) { string ip = System.IO.File.ReadAllText(@"settings.txt"); this.mainWindow = mainWindow; m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress[] ipAddress = Dns.GetHostAddresses(ip); IPEndPoint ipEnd = new IPEndPoint(ipAddress[0], 8221); m_clientSocket.Connect(ipEnd); if (m_clientSocket.Connected) { //clientMW._connected = true; mainWindow.reloadGame(); WaitForData(); } }
public void OnClientConnect(IAsyncResult asyn) { //string userName = "******"; // to be edited try { m_socWorker[m_clientCount] = m_socListener.EndAccept(asyn); //Client _newUser = new Client(m_socWorker[m_clientCount], userName); //clients.Add(_newUser); WaitForData(m_socWorker[m_clientCount]); ++m_clientCount; m_socListener.BeginAccept(new AsyncCallback(OnClientConnect), null); mainWindow.reloadGame(); } catch (Exception ex) { MessageBox.Show("Something bad happened : " + ex.Message, "Battle Tetrix", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Application.Restart(); } }