示例#1
0
        private static void Update()
        {
            while (true)
            {
                Dictionary <long, MatchmakingEntry> sessions     = new Dictionary <long, MatchmakingEntry>(GameMatchmakingManager.m_queue);
                Dictionary <long, GameAvatar>       offlineUsers = new Dictionary <long, GameAvatar>(GameMatchmakingManager.m_offlinePlayers);

                foreach (MatchmakingEntry entry in sessions.Values)
                {
                    if (entry.MatchConfirmation)
                    {
                        continue;
                    }
                    if (ServerStatus.Status == ServerStatusType.SHUTDOWN_STARTED ||
                        ServerStatus.Status == ServerStatusType.MAINTENANCE ||
                        ServerStatus.Status == ServerStatusType.COOLDOWN_AFTER_MAINTENANCE)
                    {
                        entry.Session.SendMessage(new GameMatchmakingResultMessage(), 9);
                        entry.MatchConfirmation = true;
                        continue;
                    }

                    GameAvatar enemy = GameMatchmakingManager.FindEnemy(entry, offlineUsers);

                    if (enemy != null)
                    {
                        entry.Session.SendMessage(new GameMatchmakingResultMessage
                        {
                            EnemyId = enemy.Id
                        }, 9);
                        entry.MatchConfirmation = true;
                    }
                }

                Thread.Sleep(250);
            }
        }