package com.seer.teach.netty.im.handler.mq.impl.redisChannelPush;

import com.seer.teach.common.dto.mq.StringDTO;
import com.seer.teach.common.enums.im.RedisChannelPushTopTagEnum;
import com.seer.teach.netty.im.handler.mq.ImRedisChannelPushHandler;
import com.seer.teach.netty.im.utils.PushTimeStampUtils;
import com.seer.teach.netty.im.utils.RedisAudioChannelSubscriber;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class PushLlmAudioHandler implements ImRedisChannelPushHandler<StringDTO> {

    private final RedisAudioChannelSubscriber redisSseChannelSubscriber;

    /**
     * 处理消息，同时动态订阅频道
     */
    @Override
    public void handle(StringDTO messageBody, String device) {
        PushTimeStampUtils.updateTimeStamp(messageBody.getData());
        String channelName = messageBody.getData();
        redisSseChannelSubscriber.subscribeChannel(channelName, device);
    }

    @Override
    public Class<StringDTO> getType() {
        return StringDTO.class;
    }

    @Override
    public String getTag() {
        return RedisChannelPushTopTagEnum.PUSH_LLM_AUDIO.getTag();
    }
}
