Beispiel #1
0
        public void Loop()
        {
            Server.AcceptConnection();

            var list = Authentication.Connections;

            for (var i = 0; i < list.Count; i++)
            {
                list[i].ReceiveData();

                if (Environment.TickCount >= pingTick + PingTime)
                {
                    pingTick = Environment.TickCount;
                    ping.Send(list[i], false);
                }

                if (!list[i].Connected)
                {
                    Disconnected.Add(list[i]);
                }
            }

            // Remove disconnected users.
            if (Disconnected.Count > 0)
            {
                for (var i = 0; i < Disconnected.Count; i++)
                {
                    Authentication.Remove(Disconnected[i]);
                    Global.WriteLog($"Connection Removed {Disconnected[i].IpAddress.Ip}", "Black");
                }

                Disconnected.Clear();
            }
        }