Ejemplo n.º 1
0
        void launchGameFromItem(WorkerArgs args, LaunchItem launchItem, Dictionary <string, DateTime> accountLaunchTimes)
        {
            Logger.WriteDebug("launchGameFromItem on thread {0}: Account={1}, Server={2}, Char={3}",
                              Thread.CurrentThread.ManagedThreadId,
                              launchItem.AccountName, launchItem.ServerName, launchItem.CharacterSelected);
            LaunchManager mgr = new LaunchManager(args.ClientExeLocation, launchItem, accountLaunchTimes);

            mgr.ReportStatusEvent += (status, item) => FireReportLaunchItemStatusEvent(status, item);
            LaunchManager.LaunchManagerResult launchResult;
            GameSession session = null;

            try
            {
                session = _gameSessionMap.StartLaunchingSession(launchItem.ServerName, launchItem.AccountName);
                FireReportAccountStatusEvent(ServerAccountStatusEnum.Starting, launchItem);
                launchResult = mgr.LaunchGameHandlingDelaysAndTitles(_worker);
            }
            finally
            {
                _gameSessionMap.EndLaunchingSession(launchItem.ServerName, launchItem.AccountName);
            }

            if (launchResult.Success)
            {
                ++_serverIndex;
                // Let's just wait for game monitor to check if the character list changed
                // b/c the AccountManager is subscribed for that event
                //CallUiNotifyAvailableCharactersChanged(); // Pick up any characters - experimental 2017-04-10
                // CallUiLoadUserAccounts(); // Pick up any characters - before 2017-04-10
                _gameSessionMap.StartSessionWatcher(session);
                session.WindowHwnd = launchResult.Hwnd;
                // session.ProcessId is already populated
                FireReportLaunchItemStatusEvent(GameStatusNotice.CreateSuccess("Launched"), launchItem);
            }
        }
Ejemplo n.º 2
0
        void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerArgs args = (e.Argument as WorkerArgs);

            if (args == null)
            {
                return;
            }
            lock (_launchTimingLock)
            {
                _lastLaunchInitiatedUtc = DateTime.UtcNow;
            }
            int serverIndex = 0;

            System.Collections.Concurrent.ConcurrentQueue <LaunchItem> globalQueue = args.ConcurrentLaunchQueue;
            int serverTotal = globalQueue.Count;

            if (serverTotal == 0)
            {
                return;
            }

            LaunchItem launchItem         = null;
            var        accountLaunchTimes = _gameSessionMap.GetLaunchAccountTimes();

            while (globalQueue.TryDequeue(out launchItem))
            {
                LaunchManager mgr = new LaunchManager(_launcherLocation, launchItem, accountLaunchTimes);
                mgr.ReportStatusEvent += (status, item) => HandleLaunchMgrStatus(status, item, serverIndex, serverTotal);
                LaunchManager.LaunchManagerResult launchResult;
                GameSession session = null;
                try
                {
                    session = _gameSessionMap.StartLaunchingSession(launchItem.ServerName, launchItem.AccountName);
                    UpdateAccountStatus(ServerAccountStatusEnum.Starting, launchItem);
                    launchResult = mgr.LaunchGameHandlingDelaysAndTitles(_worker);
                }
                finally
                {
                    _gameSessionMap.EndLaunchingSession(launchItem.ServerName, launchItem.AccountName);
                }

                if (launchResult.Success)
                {
                    ++serverIndex;
                    // Let's just wait for game monitor to check if the character list changed
                    // b/c the AccountManager is subscribed for that event
                    //CallUiNotifyAvailableCharactersChanged(); // Pick up any characters - experimental 2017-04-10
                    // CallUiLoadUserAccounts(); // Pick up any characters - before 2017-04-10
                    _gameSessionMap.StartSessionWatcher(session);
                    workerReportProgress("Launched", launchItem, serverIndex, serverTotal);
                }

                if (_worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
            }
        }