示例#1
0
        public async Task HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs)
        {
            var payload = Encoding.ASCII.GetString(eventArgs.ApplicationMessage.Payload);
            var message = new MqttBroadcastMessage
            {
                Payload  = System.Text.Encoding.ASCII.GetString(eventArgs.ApplicationMessage.Payload),
                Topic    = eventArgs.ApplicationMessage.Topic,
                ClientId = eventArgs.ClientId,
                Date     = System.DateTime.Now
            }.ToJsonString();
            await redisCacheService.PushBackAsync(eventArgs.ApplicationMessage.Topic, message);

            logger.Information(message);
        }