From c2bbbf311de6d95ff47e46fe23769c0d85e4d727 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 14 Nov 2023 13:24:49 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Fixed=20setQueueStatus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/socket.service.ts | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/services/socket.service.ts b/services/socket.service.ts index 64393d9..43559fa 100644 --- a/services/socket.service.ts +++ b/services/socket.service.ts @@ -26,7 +26,7 @@ export default class SocketService extends Service { "/": { events: { call: { - whitelist: ["socket.resumeSession"], + whitelist: ["socket.*"], }, // async (data) => { @@ -143,8 +143,12 @@ export default class SocketService extends Service { if (active > 0) { // 3. Get job counts - const completedJobCount = await pubClient.get("completedJobCount"); - const failedJobCount = await pubClient.get("failedJobCount"); + const completedJobCount = await pubClient.get( + "completedJobCount" + ); + const failedJobCount = await pubClient.get( + "failedJobCount" + ); // 4. Send the counts to the active socket.io session await this.broker.call("socket.broadcast", { @@ -161,17 +165,27 @@ export default class SocketService extends Service { } } } catch (err) { - throw new MoleculerError(err, 500, "SESSION_ID_NOT_FOUND", { - data: sessionId, - }); + throw new MoleculerError( + err, + 500, + "SESSION_ID_NOT_FOUND", + { + data: sessionId, + } + ); } }, - setQueueStatus: async (ctx: Context<{}>) => { - console.log(data); + setQueueStatus: async ( + ctx: Context<{ + queueAction: string; + queueStatus: string; + }> + ) => { + const { queueAction } = ctx.params; await this.broker.call( "jobqueue.toggle", - { action: data.data.queueAction }, + { action: queueAction }, {} ); },