package com.psdc.mqtt;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MqttMsg {

    /**
     * 主题
     */
    private String topic;

    /**
     * qos
     */
    private int qos;

    /**
     * 消息体
     */
    private Map<String,Object> payload;

    /**
     * retained 是否消息留存，默认false
     */
    private Boolean retained;

    private static MqttMsg setMqttMsg(String topic,int qos,Map<String,Object> payload){
        return new MqttMsg(topic,qos,payload,false);
    }

    private static MqttMsg setMqttMsg(String topic,Map<String,Object> payload){
        return new MqttMsg(topic,1,payload,false);
    }

}
