예제 #1
0
        public async Task HandleAsync(DomainCommandContext context, InitializeCommand command)
        {
            var applicationSettings = await _applicationSettingsRepository.LoadAsync();

            var games = await _gameRepository.LoadAllAsync();

            var gameProfileId = await _gameRepository.LoadGameProfileIdAsync();

            var textureManagementSettings = await _textureManagementSettingsRepository.LoadAsync();

            var usageStatistics = await _usageStatisticsRepository.LoadAsync();

            var @event = new InitializeEvent(
                applicationSettings.Map <ApplicationSettings>(),
                games.Map <IEnumerable <Game> >(),
                gameProfileId?.Value,
                textureManagementSettings.Map <TextureManagementSettings>(),
                usageStatistics.Map <SharedModel.UsageStatistics>());

            foreach (var settings in games)
            {
                await _processWatcher.WatchAsync(settings.Id);
            }

            await context.PublishAsync(@event);
        }
        public async Task HandleAsync(DomainCommandContext context, UpdateTextureManagementSettingsCommand command)
        {
            var settings = command.Settings.Map <TextureManagementSettings>();

            await _textureManagementSettingsRepository.SaveAsync(settings);

            await context.PublishAsync(new TextureManagementSettingsUpdatedEvent(command.Settings));
        }
예제 #3
0
        public async Task HandleAsync(DomainCommandContext context, IndicateFirstLaunchCommand command)
        {
            var usageStatistics = await _usageStatisticsRepository.LoadAsync();

            usageStatistics.FirstLaunchTime = command.Time;

            await _usageStatisticsRepository.SaveAsync(usageStatistics);

            await context.PublishAsync(new FirstLaunchIndicatedEvent(command.Time));
        }
예제 #4
0
        public async Task HandleAsync(DomainCommandContext context, StarGameCommand command)
        {
            var game = await _gameRepository.LoadAsync(command.GameId);

            if (_injectionService.IsProxyLoaded(game.FilePath, _plugins.Proxy))
            {
                await context.PublishAsync(
                    new SharedEvent.GameStartedEvent(
                        game.FilePath,
                        GameLaunchingStatus.PluginAlreadyLoaded));

                return;
            }

            var result = _injectionService.Start(game.FilePath)
                             ? GameLaunchingStatus.Completed
                             : GameLaunchingStatus.Failed;

            await context.PublishAsync(new SharedEvent.GameStartedEvent(game.FilePath, result));
        }
예제 #5
0
        public async Task HandleAsync(DomainCommandContext context, UpdateApplicationSettingsCommand command)
        {
            var applicationSettings = await _applicationSettingsRepository.LoadAsync();

            applicationSettings.ApplicationCommunicationPort = command.ApplicationCommunicationPort;
            applicationSettings.ProxyCommunicationPort       = command.ProxyCommunicationPort;

            await _applicationSettingsRepository.SaveAsync(applicationSettings);

            await context.PublishAsync(new ApplicationSettingsUpdatedEvent(command.ApplicationCommunicationPort, command.ProxyCommunicationPort));
        }
예제 #6
0
        public async Task HandleAsync(DomainCommandContext context, RemoveGameProfileCommand command)
        {
            var game = await _gameRepository.LoadByGameProfileId(command.Id);

            game.RemoveGameProfile(command.Id);

            await _gameRepository.SaveAsync(game);

            await _processWatcher.UnwatchAsync(command.Id);

            await context.PublishAsync(new GameProfileRemovedEvent(game.ProfileId, command.Id));
        }
예제 #7
0
        public async Task HandleAsync(DomainCommandContext context, UpdateGameCommand command)
        {
            var game = await _gameRepository.LoadAsync(command.Id);

            game.ChangeName(command.Name);
            game.ChangeFilePath(command.FilePath);

            await _gameRepository.SaveAsync(game);

            await _processWatcher.WatchAsync(game.Id);

            await context.PublishAsync(new GameUpdatedEvent(game.Id, game.Name, game.FilePath));
        }
        public async Task HandleAsync(DomainCommandContext context, UpdateProxySettingsCommand command)
        {
            if (await UpdateAsync(command.ProxyPluginSettings))
            {
                var settings = await GetProxySettingsAsync();

                if (settings != null)
                {
                    await context.PublishAsync(new SharedEvent.ProxySettingsLoadedEvent(settings));

                    return;
                }
            }

            await context.EmitAsync(new ErrorOccuredNotification());
        }
예제 #9
0
        public async Task HandleAsync(DomainCommandContext context, LoadProxySettingsCommand command)
        {
            using (var communicator = _communicatorFactory.Create())
            {
                var result = await communicator.GetProxySettingsAsync();

                if (result.IsCompleted)
                {
                    await context.PublishAsync(new ProxySettingsLoadedEvent(result.Response.Map <ProxySettings>()));

                    return;
                }

                await context.EmitAsync(new ErrorOccuredNotification());
            }
        }
예제 #10
0
        public async Task HandleAsync(DomainCommandContext context, UpdateGameProfileCommand command)
        {
            var gameProfile = command.GameProfile.Map <GameProfile>();
            var game        = await _gameRepository.LoadByGameProfileId(gameProfile.Id);

            var profile = game.AddGameProfile(
                command.GameProfile.Id,
                command.GameProfile.Name,
                command.GameProfile.ProxyDirectoryPath,
                command.GameProfile.LogsDirectoryPath,
                command.GameProfile.PluginType,
                command.GameProfile.Direct3D11Settings.Map <Direct3D11Settings>());

            await _gameRepository.SaveAsync(game);

            await _processWatcher.WatchAsync(game.Id);

            await context.PublishAsync(new GameProfileUpdatedEvent(profile.Map <Shared.Model.GameSettings.GameProfile>()));
        }
예제 #11
0
        public async Task HandleAsync(DomainCommandContext context, AddGameProfileCommand command)
        {
            var game = await _gameRepository.LoadAsync(command.GameId);

            if (game == null)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }

            var gameProfileTemplate = game.Profiles.SingleOrDefault(entity => entity.Id == (AggregateId)command.BasedOnGameProfileId);

            if (gameProfileTemplate == null)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }

            var gameProfile = game.AddGameProfile(
                AggregateId.Generate(),
                command.Name,
                gameProfileTemplate.ProxyDirectoryPath,
                gameProfileTemplate.LogsDirectoryPath,
                gameProfileTemplate.PluginType,
                gameProfileTemplate.Direct3D11Settings);

            await _gameRepository.SaveAsync(game);

            await _processWatcher.WatchAsync(game.Id);

            var @event = new GameProfileAddedEvent(
                game.Id,
                game.ProfileId,
                gameProfile.Map <GameProfile>());

            await context.PublishAsync(@event);
        }
예제 #12
0
        public async Task HandleAsync(DomainCommandContext context, UpdateLastEditedGameProfileCommand command)
        {
            await _gameRepository.ChangeGameProfileAsync(command.Id);

            await context.PublishAsync(new LastEditedGameProfileUpdatedEvent(command.Id));
        }
예제 #13
0
 public async Task HandleAsync(DomainCommandContext context, LoadProxyActivationStatusCommand command)
 {
     var status = GetActivationStatus(command.ApplicationFilePath);
     await context.PublishAsync(new ProxyActivationStatusLoadedEvent(command.ApplicationFilePath, status));
 }