//timer event to periodically update the counters
        private void timerUpdateRequestCount_Tick(object sender, EventArgs e)
        {
            cywCounters counters = cywControl.GetCounters();

            labelRequestCount.Text   = counters.downloadCount.ToString();
            labelBufferedAmount.Text = cywControl.GetBufferedAmount().ToString();
        }
        private void buttonSend_Click(object sender, EventArgs e)
        {
            bool          error    = false;
            StringBuilder sendStr  = new StringBuilder(textBoxSendData.Text);
            cywCounters   counters = cywControl.GetCounters();

            if (checkBoxAddSendCount.Checked)
            {
                sendStr.Append(counters.uploadCount.ToString());
            }
            CywDataToSend sendData = new CywDataToSend();

            //check which option is selected for sending data to
            if (radioButtonSelectedNetworks.Checked)
            {
                //when this option is selected then the message will be sent to the all the devices which are listening to the selected networks
                using (StringReader sr = new StringReader(textBoxToNetworks.Text))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null) //split textbox text into lines
                    {
                        sendData.toNetworks.Add(line);
                    }
                }
                if (sendData.toNetworks.Count == 0)
                {
                    //when this option is selected then at least one network needs to be selected
                    MessageBox.Show("Please select at least one network", "No networks selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error = true;
                }
            }
            else if (radioButtonSessionIDs.Checked)
            {
                //when this option is selected then the message will only be sent to the session IDs entered
                if (textBoxToSessionIDs.Text != "")
                {
                    string[] parts = textBoxToSessionIDs.Text.Split(',');
                    for (int i = 0; i < parts.Length; i++)
                    {
                        int  sessionId;
                        bool success;
                        success = int.TryParse(parts[i], out sessionId);
                        if (success)
                        {
                            sendData.toSessionIDs.Add(sessionId);
                        }
                        else
                        {
                            MessageBox.Show("Error parsing session IDs. Please make sure that you have a comma delimited list of numbers.", "Session ID error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            error = true;
                        }
                    }
                }
                if (sendData.toSessionIDs.Count == 0)
                {
                    //when this option is selected then at least one session ID needs to be entered
                    MessageBox.Show("Please enter at least one session ID", "No session IDs", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error = true;
                }
            }

            if (!error)
            {
                sendData.ConvertStringForSending(sendStr.ToString());
                sendData.dataType = textBoxDataType.Text;
                int errorCode = cywControl.SendData(sendData);  //--------->send data
                if (errorCode == 0)
                {
                    //data sent
                    labelSendCount.Text = counters.uploadCount.ToString();
                }
                else
                {
                    AddLineToListbox("Send error: " + errorCode.ToString() + " " + cywControl.GetErrorCodeDescription(errorCode.ToString()), "Send Data");
                }
            }
        }