fix subscription confirmation
This commit is contained in:
+14
-8
@@ -42,13 +42,19 @@ export function processMessage(ws: WS, messageString: string): void {
|
|||||||
guardStringNotEmpty(messageObject.subscribeChannel, (subscribeChannel) => {
|
guardStringNotEmpty(messageObject.subscribeChannel, (subscribeChannel) => {
|
||||||
trackSubscription(ws, subscribeChannel);
|
trackSubscription(ws, subscribeChannel);
|
||||||
});
|
});
|
||||||
guardStringNotEmpty(messageObject.unsubscribeChannel, (unsubscribeChannel) => {
|
guardStringNotEmpty(
|
||||||
removeSubscription(ws, unsubscribeChannel);
|
messageObject.unsubscribeChannel,
|
||||||
});
|
(unsubscribeChannel) => {
|
||||||
guardStringNotEmpty(messageObject.messageChannel == "string", (messageChannel) => {
|
removeSubscription(ws, unsubscribeChannel);
|
||||||
if (!messageObject.messageBody) return;
|
}
|
||||||
sendMessage(messageChannel, messageObject.messageBody);
|
);
|
||||||
});
|
guardStringNotEmpty(
|
||||||
|
messageObject.messageChannel == "string",
|
||||||
|
(messageChannel) => {
|
||||||
|
if (!messageObject.messageBody) return;
|
||||||
|
sendMessage(messageChannel, messageObject.messageBody);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MESSAGING
|
// MESSAGING
|
||||||
@@ -71,7 +77,7 @@ export function sendMessage(channel: string, body: string): void {
|
|||||||
function confirmSubscription(ws: WS, channel: string): void {
|
function confirmSubscription(ws: WS, channel: string): void {
|
||||||
const messageObject = {
|
const messageObject = {
|
||||||
channel: channel,
|
channel: channel,
|
||||||
subscribed: subscriptions.getChannelList(ws)?.has(channel),
|
subscribed: subscriptions.getChannelList(ws) ? true : false,
|
||||||
};
|
};
|
||||||
const messageString = stringifyMessage(messageObject);
|
const messageString = stringifyMessage(messageObject);
|
||||||
console.log(messageString);
|
console.log(messageString);
|
||||||
|
|||||||
Reference in New Issue
Block a user