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

View File

@@ -5,11 +5,15 @@ export const chainInfo = JSON.parse(fs.readFileSync('../contract/version.json'))
console.log('chainInfo', chainInfo)
export async function joinChain( socket, chainId ) {
if (socket.chainId)
socket.leave(socket.chainId)
socket.join(chainId)
socket.chainId = chainId
const items = await marks.items(chainId);
for (let [token,mark] of items)
socket.emit('mark.usd', chainId, token, mark)
try {
if (socket.chainId)
socket.leave(socket.chainId)
socket.join(chainId)
socket.chainId = chainId
const items = await marks.items(chainId);
for (let [token, mark] of items)
socket.emit('mark.usd', chainId, token, mark)
} catch (e) {
console.error('joinChain', e)
}
}