package com.zsc.edu.gateway.modules.mqtt.config;

import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

@Component
@MessagingGateway(defaultRequestChannel = MqttConfig.CHANNEL_OUT)
public interface MqttSender {

    /**
     * 定义重载方法，用于消息发送
     *
     * @param payload
     */
    void sendMsg(String payload);

    /**
     * 指定topic进行消息发送
     *
     * @param topic
     * @param payload
     */
    void sendMsg(@Header(MqttHeaders.TOPIC) String topic, String payload);

    /**
     * 指定topic进行消息发送
     *
     * @param topic
     * @param retain
     * @param payload
     */
    void sendMsg(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.RETAINED) boolean retain, String payload);


    /**
     * 指定topic进行消息发送
     *
     * @param topic
     * @param qos
     * @param payload
     */
    void sendMsg(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.QOS) int qos, String payload);

    /**
     * 指定topic进行消息发送
     *
     * @param topic
     * @param qos
     * @param payload
     */
    void sendMsg(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.QOS) int qos, byte[] payload);
}
