Exemple #1
0
        //When we receive the data from the connection
        private void cbDataReceived(int Data)
        {
            int reply = 0;

            if (Data > guessAnswer)
            {
                //Guess was too big
                reply = 1;
            }
            else if (Data < guessAnswer)
            {
                //Guess was too little
                reply = -1;
            }
            else //Data == guessAnswer
            {
                //Guess was correct
                reply = 0;
                try
                {
                    Invoke(new delVoidVoid(ChangeAnswer));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            //Transmit reply
            ConnectionSocket.SendData(reply);
        }
Exemple #2
0
 private void UI_button_SendGuess_Click(object sender, EventArgs e)
 {
     if (Connection != null)
     {
         //Transmit guess
         Connection.SendData(guess);
     }
 }