fix subscription confirmation

This commit is contained in:
marlonerler
2024-07-05 00:17:24 +02:00
parent 7c7731e2cd
commit aff1aac9ec
+11 -5
View File
@@ -42,13 +42,19 @@ export function processMessage(ws: WS, messageString: string): void {
guardStringNotEmpty(messageObject.subscribeChannel, (subscribeChannel) => {
trackSubscription(ws, subscribeChannel);
});
guardStringNotEmpty(messageObject.unsubscribeChannel, (unsubscribeChannel) => {
guardStringNotEmpty(
messageObject.unsubscribeChannel,
(unsubscribeChannel) => {
removeSubscription(ws, unsubscribeChannel);
});
guardStringNotEmpty(messageObject.messageChannel == "string", (messageChannel) => {
}
);
guardStringNotEmpty(
messageObject.messageChannel == "string",
(messageChannel) => {
if (!messageObject.messageBody) return;
sendMessage(messageChannel, messageObject.messageBody);
});
}
);
}
// MESSAGING
@@ -71,7 +77,7 @@ export function sendMessage(channel: string, body: string): void {
function confirmSubscription(ws: WS, channel: string): void {
const messageObject = {
channel: channel,
subscribed: subscriptions.getChannelList(ws)?.has(channel),
subscribed: subscriptions.getChannelList(ws) ? true : false,
};
const messageString = stringifyMessage(messageObject);
console.log(messageString);