From 1011ab3bfb35763e7b0311196806bd693c3e5deb Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Tue, 20 Feb 2024 16:21:50 +0100 Subject: [PATCH] refactor(cluster): allow to call onMessage() with a cluster response The Redis adapter is currently the only adapter which makes a distinction between publishing messages (one channel for all) and responses (one channel for each node). --- lib/cluster-adapter.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/cluster-adapter.ts b/lib/cluster-adapter.ts index 083db18..f5242c2 100644 --- a/lib/cluster-adapter.ts +++ b/lib/cluster-adapter.ts @@ -299,6 +299,19 @@ export abstract class ClusterAdapter extends Adapter { break; } + // @ts-ignore + case MessageType.BROADCAST_CLIENT_COUNT: + // @ts-ignore + case MessageType.BROADCAST_ACK: + // @ts-ignore + case MessageType.FETCH_SOCKETS_RESPONSE: + // @ts-ignore + case MessageType.SERVER_SIDE_EMIT_RESPONSE: + // extending classes may not make a distinction between a ClusterMessage and a ClusterResponse payload and may + // always call the onMessage() method + this.onResponse(message); + break; + default: debug("unknown message type: %s", message.type); }