@allgemein/eventbus
Version:
55 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MqttReader = void 0;
const AbstractMqttConnection_1 = require("./AbstractMqttConnection");
class MqttReader extends AbstractMqttConnection_1.AbstractMqttConnection {
constructor(topic, channel, options) {
super(options);
this.topic = 'any';
// this.channel = channel;
// this.topic = topic;
// const _options = _.clone(options);
// this.options = options['reader'] ? _.merge(_options, _options['reader']) : _options;
}
async close() {
const client = await this.getClient(false);
return new Promise(async (resolve, reject) => {
// try {
// client.punsubscribe();
// } catch (e) {
// }
//
// try {
// await this.quit();
// resolve();
// } catch (e) {
// reject(e);
// }
});
}
async open() {
if (this.ready) {
return this.channel;
}
const client = await this.getClient();
return new Promise((resolve, reject) => {
// client.psubscribe(this.topic + '::*', (err, channel) => {
// if (err) {
// err.message = err.message + ' (#open / subscribe)';
// console.error(err);
// reject(err);
// } else {
// client.on(E_PMESSAGE, this.onPMessage.bind(this));
// this.ready = true;
// this.redisChannel = channel;
// resolve(channel);
// }
// });
});
}
subscribe(callback) {
// this.on('message', callback);
}
}
exports.MqttReader = MqttReader;
//# sourceMappingURL=MqttReader.js.map