Exemplo n.º 1
0
        private void tsmiSend_Click(object sender, EventArgs e)
        {
            var selectedItems = lvClients.SelectedItems;

            if (selectedItems.Count > 0)
            {
                string datagram = Microsoft.VisualBasic.Interaction.InputBox("please input something", "SendToTcpClient", string.Empty, -1, -1);
                byte[] sendData;
                if (rbtnH16.Checked == true)
                {
                    sendData = StaticMethod.StringToByteArray(datagram);
                }
                else
                {
                    sendData = Encoding.ASCII.GetBytes(datagram);
                }
                for (int i = 0; i < selectedItems.Count; i++)
                {
                    string ip = selectedItems[i].SubItems[1].Text + ":" + selectedItems[i].SubItems[2].Text;
                    aas.SendToSelectedClient(ip, sendData);
                }
            }
        }
Exemplo n.º 2
0
        private void btn_Send_Click(object sender, EventArgs e)
        {
            string data;

            if (txtSendData.Text != string.Empty)
            {
                data = txtSendDataToAll.Text;
            }
            else
            {
                data = "hello from server!";
            }

            byte[] sendData;
            if (rbtnH16.Checked == true)
            {
                sendData = StaticMethod.StringToByteArray(data);
            }
            else
            {
                sendData = Encoding.ASCII.GetBytes(data);
            }
            aas.SendToAll(sendData);
        }