"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractListener = void 0;
const events_1 = require("events");
class AbstractListener extends events_1.EventEmitter {
    constructor(settings = {}) {
        super();
        this.settings = settings;
        this._ready = false;
        this._closed = false;
        this._ready = false;
        this._closed = false;
        this.on('ready', () => {
            this._ready = true;
        });
        this.on('closed', () => {
            this._closed = true;
        });
        this.on('newListener', (event, listener) => {
            if (event === 'ready' && this._ready) {
                listener();
            }
        });
        this.setMaxListeners(0);
    }
    _raiseIfClosed() {
        if (this._closed) {
            throw new Error('This MQTT listener is closed');
        }
    }
}
exports.AbstractListener = AbstractListener;
//# sourceMappingURL=abstract-listener.js.map