Esempio n. 1
0
        public async Task <Unit> Handle(SendMessageCommand command, CancellationToken cancellationToken)
        {
            var playerId = command.PlayerId;
            var channel  = command.Channel;
            var content  = command.Content;

            var receivedMessage = new PlayerMessage()
            {
                Channel  = "闲聊",
                Content  = WebUtility.HtmlEncode(content),
                Sender   = _account.PlayerName,
                PlayerId = _account.PlayerId
            };

            await _mudProvider.ShowChat(receivedMessage);


            await _bus.RaiseEvent(new SendMessageEvent(playerId, content)).ConfigureAwait(false);

            //新手任务
            var chatTimes = await _redisDb.StringGet <int>(string.Format(RedisKey.ChatTimes, playerId));

            if (chatTimes <= 0)
            {
                await _queueHandler.SendQueueMessage(new CompleteQuestNewbieQuestQueue(playerId, NewbieQuestEnum.第一次聊天));
            }
            chatTimes++;
            await _redisDb.StringSet(string.Format(RedisKey.ChatTimes, playerId), chatTimes);

            return(Unit.Value);
        }