add check before connect on stream

This commit is contained in:
tjs 2023-08-17 16:13:12 -04:00
parent 54de7c6e84
commit 754fb16da0
1 changed files with 5 additions and 1 deletions

View File

@ -67,15 +67,19 @@ export function subscribeOnStream(
quoteAddress: symbolInfo.quote_token,
},
}
if (!isOpen(socket)) {
console.warn('Socket Closed')
socket.addEventListener('open', (_event) => {
if (!msg.data.baseAddress || msg.data.quoteAddress) return
socket.send(JSON.stringify(msg))
})
return
}
console.warn('[subscribeBars birdeye]')
socket.send(JSON.stringify(msg))
if (msg.data.baseAddress && msg.data.quoteAddress) {
socket.send(JSON.stringify(msg))
}
}
export function unsubscribeFromStream() {