//**********************************************************************//
        // Button cluck for the car arrived button.  All it does is send the    //
        // string "Car" to the server.                                          //
        //**********************************************************************//
        private void buttonCarArrived_Click(object sender, EventArgs e)
        {
            // Create a message to send to server
            MessageProtocol sendCarMessage = new MessageProtocol(uniqueIDNumber, "CarSent", "-");

            sendString(sendCarMessage.GetMessageToSend(), textBoxLightIP.Text);
        }
 private void timer_Tick(object sender, EventArgs e)
 {
     // If the client is connected, send a car every once in a while
     if (uniqueIDNumber != null && randomGen.Next(4) == 0)
     {
         MessageProtocol sendCarMessage = new MessageProtocol(uniqueIDNumber, "CarSent", "-");
         sendString(sendCarMessage.GetMessageToSend(), textBoxLightIP.Text);
     }
 }
        //*********************************************************************//
        // Form closing.  If the connection thread was ever created then kill  //
        // it off.                                                             //
        //*********************************************************************//
        private void FormTrafficLight_FormClosing(object sender, FormClosingEventArgs e)
        {
            MessageProtocol disconncetionMessage = new MessageProtocol(uniqueIDNumber, "ClientDisconnecting", "-");

            sendString(disconncetionMessage.GetMessageToSend(), textBoxLightIP.Text);

            if (threadConnection != null)
            {
                threadConnection.StopThread();
            }
        }
        private void connectServerButton_Click(object sender, EventArgs e)
        {
            // Create message to send connection request
            MessageProtocol connectMessage = new MessageProtocol("#", "ConnectionRequest", "-");

            if (ValidateIPAddress() == true)
            {
                waitingToConnect = true;

                // Send string requesting the unique ID assigned by the server
                sendString(connectMessage.GetMessageToSend(), textBoxLightIP.Text);
            }
        }