//creates the communication thread public ClientComm(string ip, ClientDblBuff CB) { IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), 3004); clientSocket = new TcpClient(); clientSocket.Connect(serverEndPoint); commBuffer = CB; receiveBuf = new byte[messageSize]; clientStream = clientSocket.GetStream(); players = 0; encoder = new ASCIIEncoding(); }
//creates the communication thread public ClientComm(string ip, ClientDblBuff CB) { IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), 3004); clientSocket = new TcpClient(); clientSocket.Connect(serverEndPoint); commBuffer = CB; receiveBuf = new byte[messageSize]; clientStream = clientSocket.GetStream(); players = 0; encoder = new ASCIIEncoding(); }
//"play" button on play canvas "start hosting" on host canvas private void startHostingGame_Click(object sender, RoutedEventArgs e) { parent.Children.Remove(parent.Children[1]); /*var connecting = new WaitingOnConnectionWindow(); connecting.Show(); */ WondersServer server = new WondersServer(3004); ThreadStart ts = new ThreadStart(server.serverStart); Thread serverThread = new Thread(ts); serverThread.Start(); ClientDblBuff commBuffer = new ClientDblBuff(); ClientComm client = new ClientComm("127.0.0.1", commBuffer); ThreadStart cs = new ThreadStart(client.ClientRun); Thread clientThread = new Thread(cs); clientThread.Start(); WaitingToStartCanvasHost wait = new WaitingToStartCanvasHost(parent); }