Example #1
0
        public static void actualizacion()
        {
            while (server)
            {
                Thread.Sleep(1000);

                try {
                    List<string[]> sl = new List<string[]>();

                    foreach (conectado c in lista)
                    {
                        string[] a = new string[3];
                        a[0] = c.estado;
                        a[1] = c.id.ToString();
                        a[2] = c.nombre;
                        sl.Add(a);
                    }

                    lista_usuarios l = new lista_usuarios();
                    l.lista = sl;

                    foreach (Socket i in upl)
                    {
                        string ipuerto=i.LocalEndPoint.ToString();
                        string[] s=ipuerto.Split(':');
                        bool auncon = false;

                        foreach (conectado c in lista)
                        {
                            string conected=c.cliente.LocalEndPoint.ToString();
                            string[] cc = conected.Split(':');

                            if (s[0] == cc[0])
                            {
                                i.Send(l.toBytes());
                                auncon = true;
                            }
                        }
                        if (!auncon)
                        {
                            upl.Remove(i);
                            i.Disconnect(true);
                        }
                    }

                }
                catch
                {
                    server = false;
                }
            }
        }
Example #2
0
        public void actualiza()
        {
            int readbytes;
            while (hilo)
            {
                try {
                    byte[] reciveBuffer = new byte[actua.SendBufferSize];

                    readbytes = actua.Receive(reciveBuffer);

                    if (readbytes > 0 && hilo == true)
                    {
                        lista_usuarios d = new lista_usuarios(reciveBuffer);

                        actualizacion a = new actualizacion(actualiza2step);
                        this.Invoke(a, new object[] { d });
                    }
                }
                catch
                {

                }
            }
        }
Example #3
0
 public void actualiza2step(lista_usuarios d)
 {
     flp_conectados.Controls.Clear();
     foreach (string[]i in d.lista)
     {
         if (int.Parse(i[1]) != this.id)
         {
             c = new c_conectado(i[0], int.Parse(i[1]), i[2]);
             c.Click += new EventHandler(clickconectado);
             c.pb_estatus.Click+= new EventHandler(clickconectado);
             c.txt_nombreConectado.Click += new EventHandler(clickconectado);
             flp_conectados.Controls.Add(c);
         }
     }
 }