@softwaredevelopment/node-red-contrib-bodhi-device-housekeeping
Version:
housekeeping device for bodhi node red
40 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventManager = void 0;
const utils_1 = require("./utils");
class EventManager {
constructor() {
this.logger = new utils_1.CustomLogger('Custom', 'debug');
}
get name() {
return this._name;
}
set name(value) {
this.logger.debug(`XXX Setting name to ${value} from ${this._name}`);
this._name = value;
}
get bodhiEvents() {
return this._emitter;
}
set bodhiEvents(value) {
this._emitter = value;
}
get emitterType() {
return this._emitterType;
}
set emitterType(value) {
this._emitterType = value;
}
emitEvent(topic, payload, deviceCategory = 'local') {
this.logger.info(`Emitted event on topic '${topic}' with payload ${JSON.stringify(payload)}`);
const eventData = {
topic,
payload,
deviceCategory,
};
this._emitter.emit(this._emitterType, JSON.stringify(eventData));
}
}
exports.EventManager = EventManager;
// export const events = new EventManager();
//# sourceMappingURL=events.manager.js.map