private Task OnPlayerSignedInDomainEventAsync(PlayerSignedInDomainEvent evt)
        {
            var playerDto = DomainGameService.MapToPlayerDto(evt.Player);

            return(PublishIfEnabledAsync(PlayerSignedInEvent.FromPlayer(
                                             playerDto
                                             )));
        }
Beispiel #2
0
        public async Task <PlayerDto> SignInAsync(PlayerSignInRequest request)
        {
            var playerId   = request?.PlayerId ?? throw new ArgumentNullException(nameof(request.PlayerId));
            var playerName = request?.PlayerName ?? GetTempPlayerName();

            if (!_players.ContainsKey(playerId))
            {
                var player = new Player(
                    id: playerId,
                    name: playerName
                    );
                _players.Add(playerId, player);
                await _eventBus.PublishAsync(PlayerSignedInDomainEvent.FromPlayer(player));
            }
            return(MapToPlayerDto(_players[playerId]));
        }
 private void UnsubscribeAll()
 {
     _eventBus.Unsubscribe <GameStateChangedDomainEvent>(GameStateChangedDomainEvent.GetId(),
                                                         OnGameStateChangedDomainEventAsync);
     _eventBus.Unsubscribe <PlayerAddedToVesselRoleDomainEvent>(PlayerAddedToVesselRoleDomainEvent.GetId(),
                                                                OnPlayerAddedToVesselRoleDomainEventAsync);
     _eventBus.Unsubscribe <PlayerJoinedGameDomainEvent>(PlayerJoinedGameDomainEvent.GetId(),
                                                         OnPlayerJoinedGameDomainEventAsync);
     _eventBus.Unsubscribe <PlayerLeftGameDomainEvent>(PlayerLeftGameDomainEvent.GetId(),
                                                       OnPlayerLeftGameDomainEventAsync);
     _eventBus.Unsubscribe <PlayerRemovedFromVesselRoleDomainEvent>(PlayerRemovedFromVesselRoleDomainEvent.GetId(),
                                                                    OnPlayerRemovedFromVesselRoleDomainEventAsync);
     _eventBus.Unsubscribe <PlayerSignedInDomainEvent>(PlayerSignedInDomainEvent.GetId(),
                                                       OnPlayerSignedInDomainEventAsync);
     _eventBus.Unsubscribe <PlayerSignedOutDomainEvent>(PlayerSignedOutDomainEvent.GetId(),
                                                        OnPlayerSignedOutDomainEventAsync);
     _eventBus.Unsubscribe <VesselStateChangedDomainEvent>(VesselStateChangedDomainEvent.GetId(),
                                                           OnVesselStateChangedDomainEventAsync);
 }