package com.ruoyi.system.domain;

import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;

public class MqttClientWrapper {
    private String fixedAddress; // 手动配置的固定地址
    private String subscribeTopic; // 最终订阅主题（+/固定地址）
    private MqttClient mqttClient; // 独立的MQTT客户端实例
    private MqttConnectOptions mqttConnectOptions; // 独立的连接配置
    private boolean isConnected; // 连接状态
    private int qos; // QOS等级
    private volatile boolean isReconnecting;

    public boolean isReconnecting() {
        return isReconnecting;
    }

    public void setReconnecting(boolean reconnecting) {
        isReconnecting = reconnecting;
    }

    // 构造方法
    public MqttClientWrapper(String fixedAddress, String subscribeTopic, MqttClient mqttClient, MqttConnectOptions options, int qos) {
        this.fixedAddress = fixedAddress;
        this.subscribeTopic = subscribeTopic;
        this.mqttClient = mqttClient;
        this.mqttConnectOptions = options;
        this.qos = qos;
        this.isConnected = mqttClient.isConnected();
    }

    // getter/setter
    public String getFixedAddress() { return fixedAddress; }
    public void setFixedAddress(String fixedAddress) { this.fixedAddress = fixedAddress; }
    public String getSubscribeTopic() { return subscribeTopic; }
    public void setSubscribeTopic(String subscribeTopic) { this.subscribeTopic = subscribeTopic; }
    public MqttClient getMqttClient() { return mqttClient; }
    public void setMqttClient(MqttClient mqttClient) { this.mqttClient = mqttClient; }
    public MqttConnectOptions getMqttConnectOptions() { return mqttConnectOptions; }
    public void setMqttConnectOptions(MqttConnectOptions mqttConnectOptions) { this.mqttConnectOptions = mqttConnectOptions; }
    public boolean isConnected() { return isConnected; }
    public void setConnected(boolean connected) { isConnected = connected; }
    public int getQos() { return qos; }
    public void setQos(int qos) { this.qos = qos; }
}
