private Task OnPlayerJoinedGameDomainEventAsync(PlayerJoinedGameDomainEvent evt)
        {
            var playerDto = DomainGameService.MapToPlayerDto(evt.Player);

            return(PublishIfEnabledAsync(PlayerJoinedGameEvent.FromPlayerInGame(
                                             evt.GameId,
                                             playerDto
                                             )));
        }
Beispiel #2
0
        public async Task OnPlayerJoinedGameAsync(PlayerJoinedGameEvent evt)
        {
            // Lookup all clients that are already in the game and notify them
            var connectionIds = await GetPlayerConnectionsForGameAsync(evt.GameId);

            foreach (var connectionId in connectionIds)
            {
                var client = _hubContext.Clients.Client(connectionId);
                await client?.SendAsync("PlayerJoinedGame", evt);
            }
        }
Beispiel #3
0
 private void UnsubscribeAll()
 {
     _eventBus.Unsubscribe <ChatMessageSentEvent>(ChatMessageSentEvent.GetId(), OnChatMessageSentEventAsync);
     _eventBus.Unsubscribe <GameStateChangedEvent>(GameStateChangedEvent.GetId(), OnGameStateChangedEventAsync);
     _eventBus.Unsubscribe <PlayerAddedToVesselRoleEvent>(PlayerAddedToVesselRoleEvent.GetId(), OnPlayerAddedToVesselRoleEventAsync);
     _eventBus.Unsubscribe <PlayerJoinedGameEvent>(PlayerJoinedGameEvent.GetId(), OnPlayerJoinedGameEventAsync);
     _eventBus.Unsubscribe <PlayerLeftGameEvent>(PlayerLeftGameEvent.GetId(), OnPlayerLeftGameEventAsync);
     _eventBus.Unsubscribe <PlayerRemovedFromVesselRoleEvent>(PlayerRemovedFromVesselRoleEvent.GetId(), OnPlayerRemovedFromVesselRoleEventAsync);
     _eventBus.Unsubscribe <PlayerSignedInEvent>(PlayerSignedInEvent.GetId(), OnPlayerSignedInEventAsync);
     _eventBus.Unsubscribe <PlayerSignedOutEvent>(PlayerSignedOutEvent.GetId(), OnPlayerSignedOutEventAsync);
     _eventBus.Unsubscribe <VesselMovedInDirectionEvent>(VesselMovedInDirectionEvent.GetId(), OnVesselMovedInDirectionEventAsync);
     _eventBus.Unsubscribe <VesselStateChangedEvent>(VesselStateChangedEvent.GetId(), OnVesselStateChangedEventAsync);
 }
Beispiel #4
0
 protected async Task OnPlayerJoinedGameEventAsync(PlayerJoinedGameEvent evt) =>
 await OnEventAsync(evt);