All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.smartboot.mqtt.client.Subscribe Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) [2022] smartboot [[email protected]]
 *
 *  企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
 *
 *  Enterprise users are required to use this project reasonably
 *  and legally in accordance with the AGPL-3.0 open source agreement
 *  without special permission from the smartboot organization.
 */

package org.smartboot.mqtt.client;

import org.smartboot.mqtt.common.enums.MqttQoS;
import org.smartboot.mqtt.common.message.MqttPublishMessage;

import java.util.function.BiConsumer;

/**
 * @author 三刀([email protected])
 * @version V1.0 , 2022/4/7
 */
public class Subscribe {
    private final String topicFilter;
    private final MqttQoS qoS;
    private final BiConsumer consumer;

    /**
     * This topic has unsubscribed.
     */
    private volatile boolean unsubscribed;
    private volatile long unsubscribedTime = -1L;

    public Subscribe(String topicFilter, MqttQoS qoS, BiConsumer consumer) {
        this.topicFilter = topicFilter;
        this.qoS = qoS;
        this.consumer = consumer;
    }

    public String getTopicFilter() {
        return topicFilter;
    }

    public MqttQoS getQoS() {
        return qoS;
    }

    public BiConsumer getConsumer() {
        return consumer;
    }

    public boolean getUnsubscribed() {
        return unsubscribed;
    }

    public void setUnsubscribed(boolean unsubscribed) {
        this.unsubscribed = unsubscribed;
        this.unsubscribedTime = System.currentTimeMillis();
    }

    public long getUnsubscribedTime() {
        return unsubscribedTime;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy