Esempio n. 1
0
        /// <summary>
        ///     Called when [cycle].
        /// </summary>
        internal void OnCycle()
        {
            try
            {
                bool flag  = WorkActiveRoomsAddQueue();
                bool flag2 = WorkActiveRoomsRemoveQueue();
                bool flag3 = WorkActiveRoomsUpdateQueue();
                if (flag || flag2 || flag3)
                {
                    SortActiveRooms();
                }
                bool flag4 = WorkVotedRoomsAddQueue();
                bool flag5 = WorkVotedRoomsRemoveQueue();
                if (flag4 || flag5)
                {
                    SortVotedRooms();
                }

                Yupi.GetGame().RoomManagerCycleEnded = true;
            }
            catch (Exception ex)
            {
                ServerLogManager.LogThreadException(ex.ToString(), "RoomManager.OnCycle Exception --> Not inclusive");
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Broadcasts the packets.
        /// </summary>
        private void BroadcastPackets()
        {
            try
            {
                if (!_broadcastQueue.Any())
                {
                    return;
                }

                DateTime now = DateTime.Now;
                byte[]   bytes;

                _broadcastQueue.TryDequeue(out bytes);

                foreach (GameClient current in Clients.Values.Where(current => current?.GetConnection() != null))
                {
                    current.GetConnection().SendData(bytes);
                }

                TimeSpan timeSpan = DateTime.Now - now;

                if (timeSpan.TotalSeconds > 3.0)
                {
                    Console.WriteLine("GameClientManager.BroadcastPackets spent: {0} seconds in working.", timeSpan.TotalSeconds);
                }
            }
            catch (Exception ex)
            {
                ServerLogManager.LogThreadException(ex.ToString(), "GameClientManager.BroadcastPackets Exception --> Not inclusive");
            }
        }
Esempio n. 3
0
 /// <summary>
 ///     Finnitoes this instance.
 /// </summary>
 private void Finnito()
 {
     try
     {
         DeliverItems();
         CloseTradeClean();
     }
     catch (Exception ex)
     {
         ServerLogManager.LogThreadException(ex.ToString(), "Trade task");
     }
 }
Esempio n. 4
0
        /// <summary>
        ///     Called when [cycle].
        /// </summary>
        internal void OnCycle()
        {
            try
            {
                AddClients();
                RemoveClients();
                GiveBadges();
                BroadcastPackets();

                Yupi.GetGame().ClientManagerCycleEnded = true;
            }
            catch (Exception ex)
            {
                ServerLogManager.LogThreadException(ex.ToString(), "GameClientManager.OnCycle Exception --> Not inclusive");
            }
        }
Esempio n. 5
0
        /// <summary>
        ///     Gives the badges.
        /// </summary>
        private void GiveBadges()
        {
            try
            {
                DateTime now = DateTime.Now;

                if (_badgeQueue.Count > 0)
                {
                    lock (_badgeQueue.SyncRoot)
                    {
                        while (_badgeQueue.Count > 0)
                        {
                            string badge = (string)_badgeQueue.Dequeue();

                            foreach (GameClient current in Clients.Values.Where(current => current.GetHabbo() != null))
                            {
                                current.GetHabbo().GetBadgeComponent().GiveBadge(badge, true, current);
                                current.SendNotif(Yupi.GetLanguage().GetVar("user_earn_badge"));
                            }
                        }
                    }
                }

                TimeSpan timeSpan = DateTime.Now - now;

                if (timeSpan.TotalSeconds > 3.0)
                {
                    Console.WriteLine("GameClientManager.GiveBadges spent: {0} seconds in working.",
                                      timeSpan.TotalSeconds);
                }
            }
            catch (Exception ex)
            {
                ServerLogManager.LogThreadException(ex.ToString(),
                                                    "GameClientManager.GiveBadges Exception --> Not inclusive");
            }
        }