Beispiel #1
0
        public async Task SendMessageAsync(ChatMessage message)
        {
            var player = await _signInService.GetSignedInPlayerAsync(message.FromPlayerId);

            message.FromPlayerName = player.Name;
            await _eventBus.PublishAsync(ChatMessageSentEvent.FromMessage(message));
        }
Beispiel #2
0
        public async Task GetSignedInPlayerAsync(Guid invocationId, Guid playerId)
        {
            try
            {
                var signedInPlayer = await _signInService.GetSignedInPlayerAsync(playerId);

                if (signedInPlayer == null)
                {
                    var connectionIds = _playerConnections.GetAll(playerId);
                    foreach (var connectionId in connectionIds)
                    {
                        _playerConnections.SetPlayerId(connectionId, null);
                    }
                }
                await ResolveValueAsync(Clients.Caller, nameof(GetSignedInPlayerAsync), invocationId, signedInPlayer);
            }
            catch (Exception ex)
            {
                await RejectAsync(Clients.Caller, nameof(GetSignedInPlayerAsync), invocationId, ex.Message);
            }
        }