Exemplo n.º 1
0
        //Primary Server Controller Actions
        private void ClienteConectado(TCPSocketServer server, SocketConnectArgs e)
        {
            if (this.lstConectados.InvokeRequired)
            {
                // It's on a different thread, so use Invoke
                //envia uma mensagem de boas vindas ao cliente
                server.SendMessage("Welcome to xprotector Sockets server\nWaiting credentials.", e.clientID);

                this.Invoke(new AddClientCallback(this.AddClient), new object[] { e.clientID + ":" + e.ConnectedIP.ToString() });
            }
            else
            {
                lstConectados.Items.Add("Cliente conectado: " + e.ConnectedIP.ToString());
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //envia mensagem para o cliente selecionado..
            if (lstConectados.Items.Count > 0 || lstConectados.SelectedIndex != 0)
            {
                string[] selecionado = lstConectados.SelectedItem.ToString().Split(':');
                int      id          = int.Parse(selecionado[0]);

                mainServer.SendMessage(txtCommand.Text, id);
            }
            else
            {
                MessageBox.Show("Selecione um cliente conectado antes de enviar o commando....");
            }
        }