コード例 #1
0
 private string GetServerAccountKey(GameSession gameSession)
 {
     return(GetServerAccountKey(gameSession.ServerName, gameSession.AccountName));
 }
コード例 #2
0
        void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerArgs args = (e.Argument as WorkerArgs);

            if (args == null)
            {
                return;
            }
            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);
                }
                else
                {
                    globalQueue.Enqueue(launchItem);
                    workerReportProgress("Requeued", launchItem, serverIndex, serverTotal);
                }

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