redis pub/sub fix

This commit is contained in:
tim
2025-05-06 22:27:14 -04:00
parent 7f4c301491
commit 008b6793d1
7 changed files with 68 additions and 27 deletions

25
pool.js
View File

@@ -19,17 +19,22 @@ export function unsubPools( socket, chainId, addresses ) {
export async function subOHLCs( socket, chainId, poolPeriods) {
console.log('subOHLCs', chainId, poolPeriods)
for(const key of poolPeriods) {
const room = `${chainId}|${key}`;
socket.join(room)
let ohlc = await ohlcs.get(chainId,key);
console.log('got ohlc', ohlc)
if (typeof(ohlc)==='string') {
ohlc = JSON.parse(ohlc)
try {
console.log('subOHLCs', chainId, poolPeriods)
for (const key of poolPeriods) {
const room = `${chainId}|${key}`;
socket.join(room)
let ohlc = await ohlcs.get(chainId, key);
console.log('got ohlc', ohlc)
if (typeof (ohlc) === 'string') {
ohlc = JSON.parse(ohlc)
}
socket.emit('ohlc', chainId, key, ohlc)
console.log('joined room', room)
}
socket.emit('ohlc', chainId, key, ohlc)
console.log('joined room', room)
}
catch (e) {
console.error('subOHLCs', e)
}
}