UNPKG

@allgemein/eventbus

Version:
39 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MqttWriter = void 0; const Serializer_1 = require("../../utils/Serializer"); const AbstractMqttConnection_1 = require("./AbstractMqttConnection"); const lodash_1 = require("lodash"); class MqttWriter extends AbstractMqttConnection_1.AbstractMqttConnection { constructor(options) { super(options); // const _options = clone(options); // this.options = options['writer'] ? merge(_options, _options['writer']) : _options; } async open() { // const client = await this.getClient(); // client.on(E_PSUBSCRIBE, function (...args: any[]) { // console.log('subscribe', args); // }); } async publish(message, channel) { if (!(0, lodash_1.isString)(message.message)) { message.message = Serializer_1.Serializer.serialize(message.message); } const client = await this.getClient(); return new Promise((resolve, reject) => { // client.publish(message.topic + '::' + channel, message.message, (err, reply) => { // if (err) { // reject(err); // } else { // resolve(reply); // } // }); }); } async close() { await this.quit(); } } exports.MqttWriter = MqttWriter; //# sourceMappingURL=MqttWriter.js.map