redis pub/sub fix
This commit is contained in:
25
pool.js
25
pool.js
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user