示例#1
0
        private void SocketService()
        {
            UserPool.Init();

            this.tcp_listener = new TcpListener(new IPEndPoint(IPAddress.Any, (int)Settings.Get <ushort>("port")));
            this.tcp_listener.Start();

            uint  last_time       = Misc.UnixTime;
            ulong fast_ping_timer = Misc.Now;

            while (true)
            {
                ulong time = Misc.Now;
                if (!this.Running)
                {
                    return;
                }

                if (time > (fast_ping_timer + 2000))
                {
                    fast_ping_timer = time;
                    UserPool.Users.ForEach(x => { x.SendPacket(AresTcpPackets.FastPing()); });
                    Avatars.CheckAvatars();
                }

                uint time_now = Misc.UnixTime;
                this.CheckDisponse(time_now);
                this.ServiceUsers(time_now);
                ServerEvents.CycleTick();
                Thread.Sleep(25);
            }
        }