Exemplo n.º 1
0
 public async Task PublishGameEventSourceAddedAsync(GameEventSourceAdded @event)
 {
     await _hubContextWrapper.PublishToUserAsync(new System.Guid("53286016-126e-45eb-8d8c-4adfcf95ca1e"), "game_event_source_added",
                                                 new
     {
         id    = @event.Id,
         score = @event.Score,
         isWin = @event.IsWin
     }
                                                 );
 }
Exemplo n.º 2
0
        public async Task HandleAsync(AddGameEventSource command)
        {
            if (await _gameSourceRepository.ExistsAsync(command.Id))
            {
                throw new GameEventSourceAlreadyExistsException(command.Id);
            }

            var gameSource = new GameEventSource(command.Id, command.IsWin, command.Score);
            await _gameSourceRepository.AddAsync(gameSource);

            var messageId          = Guid.NewGuid().ToString("N");//this is unique per message type, each message has its own messageId in rabbitmq
            var correlationId      = _messagePropertiesAccessor.MessageProperties.CorrelationId;
            var correlationContext = _correlationContextAccessor.CorrelationContext;

            var @event = new GameEventSourceAdded(command.Id, command.Score, command.IsWin, command.UserId);
            await _busPublisher.PublishAsync(@event, messageId : messageId, correlationId : correlationId, messageContext : correlationContext);
        }