private Task OnPlayerSignedOutDomainEventAsync(PlayerSignedOutDomainEvent evt) { var playerDto = evt.Player != null?DomainGameService.MapToPlayerDto(evt.Player) : null; return(PublishIfEnabledAsync(PlayerSignedOutEvent.FromPlayer( playerDto ))); }
public async Task SignOutAsync(PlayerSignOutRequest request) { var playerId = request?.PlayerId ?? throw new ArgumentNullException(nameof(request.PlayerId)); if (!_players.ContainsKey(playerId)) { throw new KeyNotFoundException($"Player id not found ({playerId})"); } var player = _players[playerId]; _players.Remove(playerId); await _eventBus.PublishAsync(PlayerSignedOutDomainEvent.FromPlayer(player)); }
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); }