Merge pull request #38 from drift-labs/ws-undefined-guard
ws guard against undefined
This commit is contained in:
@@ -97,9 +97,11 @@ async function main() {
|
|||||||
|
|
||||||
redisClient.client.on('message', (subscribedChannel, message) => {
|
redisClient.client.on('message', (subscribedChannel, message) => {
|
||||||
const subscribers = channelSubscribers.get(subscribedChannel);
|
const subscribers = channelSubscribers.get(subscribedChannel);
|
||||||
|
if (subscribers) {
|
||||||
subscribers.forEach((ws) => {
|
subscribers.forEach((ws) => {
|
||||||
ws.send(JSON.stringify({ channel: subscribedChannel, data: message }));
|
ws.send(JSON.stringify({ channel: subscribedChannel, data: message }));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
redisClient.client.on('error', (error) => {
|
redisClient.client.on('error', (error) => {
|
||||||
@@ -180,7 +182,7 @@ async function main() {
|
|||||||
lastUpdateChannel
|
lastUpdateChannel
|
||||||
);
|
);
|
||||||
|
|
||||||
if (lastMessage !== null) {
|
if (lastMessage) {
|
||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
channel: lastUpdateChannel,
|
channel: lastUpdateChannel,
|
||||||
|
|||||||
Reference in New Issue
Block a user