"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "SocketIoTask", {
    enumerable: true,
    get: function() {
        return SocketIoTask;
    }
});
const _socketiogateway = require("../state/socket-io.gateway");
const _eventconstants = require("../constants/event.constants");
class SocketIoTask {
    socketIoGateway;
    floorStore;
    printerSocketStore;
    printerEventsCache;
    printerCache;
    fileUploadTrackerCache;
    eventEmitter2;
    logger;
    constructor(loggerFactory, socketIoGateway, floorStore, printerSocketStore, printerEventsCache, printerCache, fileUploadTrackerCache, eventEmitter2){
        this.socketIoGateway = socketIoGateway;
        this.floorStore = floorStore;
        this.printerSocketStore = printerSocketStore;
        this.printerEventsCache = printerEventsCache;
        this.printerCache = printerCache;
        this.fileUploadTrackerCache = fileUploadTrackerCache;
        this.eventEmitter2 = eventEmitter2;
        this.logger = loggerFactory(SocketIoTask.name);
        this.eventEmitter2.on(_eventconstants.socketIoConnectedEvent, async ()=>{
            await this.sendUpdate();
        });
    }
    async run() {
        await this.sendUpdate();
    }
    async sendUpdate() {
        const floors = await this.floorStore.listCache();
        const printers = await this.printerCache.listCachedPrinters(true);
        const socketStates = this.printerSocketStore.getSocketStatesById();
        const printerEvents = await this.printerEventsCache.getAllKeyValues();
        const trackedUploads = this.fileUploadTrackerCache.getUploads();
        const socketIoData = {
            printers,
            floors,
            socketStates,
            printerEvents,
            trackedUploads
        };
        this.socketIoGateway.send(_socketiogateway.IO_MESSAGES.Update, socketIoData);
    }
}

//# sourceMappingURL=socketio.task.js.map