Ejemplo n.º 1
0
        public void Close()
        {
            Settings.RUNNING = false;
            this.Running     = false;
            this.terminate   = true;

            try
            {
                this.tcp.Stop();
            }
            catch
            {
            }

            try
            {
                this.udp.Stop();
            }
            catch
            {
            }

            UserPool.Destroy();
            core.LinkHub.LeafPool.Destroy();
            UdpChannelList.Stop();

            if (Linker != null)
            {
                Linker.KillSocket();
            }
        }
Ejemplo n.º 2
0
        private void ServerThread()
        {
            this.terminate = false;

            FilterImporter.DoTasks();
            ObSalt.Init();
            CaptchaManager.Load();
            FloodControl.Reset();
            Stats.Reset();
            UserPool.Build();
            core.LinkHub.LeafPool.Build();
            Captcha.Initialize();
            UserHistory.Initialize();
            AccountManager.LoadPasswords();
            BanSystem.LoadBans();
            IdleManager.Reset();
            Proxies.Start(Helpers.UnixTime);
            IgnoreManager.init();

            if (Settings.Get <bool>("roomsearch"))
            {
                UdpChannelList.Start();
            }

            ulong last_update_check  = 0;
            ulong fast_ping_timer    = Time.Now;
            ulong channel_push_timer = (Time.Now - 1200000);
            ulong reset_floods_timer = Time.Now;
            ulong room_search_timer  = (Time.Now - 1800000);
            bool  can_web_chat       = Settings.Get <bool>("enabled", "web");

            core.LinkHub.LinkMode link_mode = (core.LinkHub.LinkMode)Settings.Get <int>("link_mode");
            Linker = new LinkLeaf.LinkClient();

            if (link_mode == LinkHub.LinkMode.Hub)
            {
                Linker.ConnectLocal();
            }

            Events.ServerStarted();

            while (true)
            {
                if (this.terminate)
                {
                    break;
                }

                ulong time = Time.Now;

                if (time > (last_update_check + (30 * 60 * 1000)))
                {
                    last_update_check = time;
                    CheckLatestVersion();
                }

                if (time > (fast_ping_timer + 2000))
                {
                    fast_ping_timer = time;

                    UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.FastPing()),
                                                 x => x.LoggedIn && x.FastPing);

                    BanSystem.AutoClearBans();
                    Avatars.CheckAvatars(time);
                }

                if (time > (reset_floods_timer + 60000))
                {
                    reset_floods_timer = time;
                    FloodControl.Reset();
                    Proxies.Updater(Helpers.UnixTime);
                }

                this.udp.ServiceUdp(time);
                this.CheckTCPListener(time);
                this.ServiceAresSockets(time);
                this.ServiceLeaves(link_mode, time);
                this.ServiceWW();
                Linker.Service(time);

                if (can_web_chat)
                {
                    this.ServiceWebSockets(time);

                    if (time > (channel_push_timer + 1200000))
                    {
                        channel_push_timer = time;
                        ib0t.ChannelPusher.Push();
                    }
                }

                if (time > (room_search_timer + 1800000))
                {
                    room_search_timer = time;

                    if (Settings.Get <bool>("roomsearch"))
                    {
                        UdpChannelList.Update();
                    }
                }

                Events.CycleTick();
                Thread.Sleep(25);
            }
        }