Server.Connector.requestGame C# (CSharp) Méthode

requestGame() public méthode

public requestGame ( String opponentip, Int32 opponentport, String myname ) : void
opponentip String
opponentport System.Int32
myname String
Résultat void
        public void requestGame(String opponentip, Int32 opponentport, String myname)
        {
            IPHostEntry ipHostInfo = Dns.Resolve(opponentip);
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, opponentport);

            clientsocket.BeginConnect(remoteEP,
                    new AsyncCallback(ConnectCallback), clientsocket);
            connectDone.WaitOne();

            requestthread = new Thread(() =>
            {

              while(true)
              {
                  if (clientsocket.Connected)
                  {
                      recieveDone.Reset();

                      StateObject state = new StateObject();
                      state.workSocket = clientsocket;
                      clientsocket.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
                                      new AsyncCallback(ReadCallback), state);

                      recieveDone.WaitOne();
                  }
              }

            });

            firstplayer = true;

            requestthread.Start();

            sendDone.Reset();
            Send(clientsocket,"startgame;" + myname);
            sendDone.WaitOne();
        }