コード例 #1
0
ファイル: _server.cs プロジェクト: eddormz/FCFM-Groups
        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;
                }
            }
        }