using Infrastructure.CloudSdk.mqttmessagecenter;
using OpenAuth.WebApi.Model.mqtt.ModelResponse;
using System.Text.Json;
using System.Text.Json.Nodes;

namespace OpenAuth.WebApi.Model.mqtt
{
    public class ThingServiceHandler : IMqttMessageHandler
    {
        private readonly ILogger<ThingServiceHandler> _logger;

        public ThingServiceHandler(ILogger<ThingServiceHandler> logger)
        {
            _logger = logger;
        }

        public bool CanHandle(string topic)
        {
            return topic.Contains("/services");
        }

        public Task HandleAsync(string topic, string payload)
        {
            //_logger.LogError($"[Service] Topic={topic}, Payload={payload}");
            //Console.WriteLine($"[Service] Topic={topic}, Payload={payload}");
            if (payload.Contains("live_start_push"))//直播
            {
                var root = JsonNode.Parse(payload)?.AsObject();
            }
            return Task.CompletedTask;
        }
    }
}
