UNPKG

neramirez-broadlink-ts

Version:

A TypeScript-enhanced Node.JS fork of broadlinkjs, designed for interacting with RM devices in homebridge-broadlink-rm. Now includes a feature for handling multiple requests to the same device, with a specific focus on supporting homebridge-broadlink-wind

36 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommandProcessor = void 0; class CommandProcessor { constructor(logger, socketHandler) { this.logger = logger; this.socketHandler = socketHandler; this.isProcessing = false; this.queue = []; } enqueue(command) { this.queue.push(command); if (!this.isProcessing) { this.processQueue(); } } async processQueue() { if (this.queue.length === 0) { this.isProcessing = false; return; } this.isProcessing = true; const command = this.queue.shift(); if (command) { try { await this.sendData(command); } catch (err) { console.error(`Error processing command: ${err}`); } this.processQueue(); } } } exports.CommandProcessor = CommandProcessor; //# sourceMappingURL=command.processor.js.map