using JiShe.CollectBus.Common.Consts;
using JiShe.CollectBus.Common.Enums;
using JiShe.CollectBus.Common.Models;
using JiShe.CollectBus.IotSystems.MessageReceiveds;
using JiShe.CollectBus.Kafka.Attributes;
using JiShe.CollectBus.Kafka.Internal;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Volo.Abp.Timing;

namespace JiShe.CollectBus.Kafka.Test
{
    public class KafkaSubscribeTest: IKafkaSubscribe
    {
        [KafkaSubscribe(ProtocolConst.TESTTOPIC, EnableBatch = false, BatchSize = 10)]

        public async Task<ISubscribeAck> KafkaSubscribeAsync(TestTopic obj)
        //public async Task<ISubscribeAck> KafkaSubscribeAsync(IEnumerable<int> obj)
        {
            Console.WriteLine($"收到订阅消息： {JsonSerializer.Serialize(obj)}");
            return SubscribeAck.Success();
        }


        //[KafkaSubscribe(ProtocolConst.SubscriberLoginIssuedEventName)]
        ////[CapSubscribe(ProtocolConst.SubscriberLoginIssuedEventName)]
        //public async Task<ISubscribeAck> LoginIssuedEvent(IssuedEventMessage issuedEventMessage)
        //{
        //    Console.WriteLine($"收到订阅消息： {JsonSerializer.Serialize(issuedEventMessage)}");
        //    return SubscribeAck.Success();
        //}

        //[KafkaSubscribe(ProtocolConst.SubscriberHeartbeatIssuedEventName)]
        ////[CapSubscribe(ProtocolConst.SubscriberHeartbeatIssuedEventName)]
        //public async Task<ISubscribeAck> HeartbeatIssuedEvent(IssuedEventMessage issuedEventMessage)
        //{
        //    Console.WriteLine($"收到订阅消息： {JsonSerializer.Serialize(issuedEventMessage)}");
        //    return SubscribeAck.Success();
        //}

        //[KafkaSubscribe(ProtocolConst.SubscriberReceivedEventName)]
        ////[CapSubscribe(ProtocolConst.SubscriberReceivedEventName)]
        //public async Task<ISubscribeAck> ReceivedEvent(MessageReceived receivedMessage)
        //{
        //    Console.WriteLine($"收到订阅消息： {JsonSerializer.Serialize(receivedMessage)}");
        //    return SubscribeAck.Success();
        //}

        //[KafkaSubscribe(ProtocolConst.SubscriberHeartbeatReceivedEventName)]
        ////[CapSubscribe(ProtocolConst.SubscriberHeartbeatReceivedEventName)]
        //public async Task<ISubscribeAck> ReceivedHeartbeatEvent(MessageReceivedHeartbeat receivedHeartbeatMessage)
        //{
        //    Console.WriteLine($"收到订阅消息： {JsonSerializer.Serialize(receivedHeartbeatMessage)}");
        //    return SubscribeAck.Success();
        //}

        //[KafkaSubscribe(ProtocolConst.SubscriberLoginReceivedEventName)]
        ////[CapSubscribe(ProtocolConst.SubscriberLoginReceivedEventName)]
        //public async Task<ISubscribeAck> ReceivedLoginEvent(MessageReceivedLogin receivedLoginMessage)
        //{
        //    Console.WriteLine($"收到订阅消息： {JsonSerializer.Serialize(receivedLoginMessage)}");
        //    return SubscribeAck.Success();
        //}
    }
}
