package com.dspread.pos.common.mqtt;

import androidx.databinding.ObservableField;

public class MqttModel {
    public final ObservableField<String> lastMessage = new ObservableField<>("");
    public final ObservableField<Boolean> isConnected = new ObservableField<>(false);
    public final ObservableField<String> connectionStatus = new ObservableField<>("Disconnected");

    private String topic;
    private int qos = 1;

    public MqttModel(String topic) {
        this.topic = topic;
    }

    public String getTopic() {
        return topic;
    }

    public int getQos() {
        return qos;
    }

    public void updateMessage(String message) {
        lastMessage.set(message);
    }

    public void updateConnectionStatus(boolean connected) {
        isConnected.set(connected);
        connectionStatus.set(connected ? "Connected" : "Disconnected");
    }
}