From e047def3a6a1564bee9ac48e88e88b618c6e97e3 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Thu, 26 Oct 2023 08:25:17 -0700 Subject: [PATCH] newclient --- .gitignore | 2 ++ example/newClient.ts | 17 +++++++++++++++++ src/dlob-subscriber/DLOBSubscriberIO.ts | 9 ++++----- src/wsConnectionManager.ts | 1 - 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 61ce045..3f820bc 100644 --- a/.gitignore +++ b/.gitignore @@ -141,3 +141,5 @@ src/**.js.map .env lib src/playground.ts + +dump.rdb \ No newline at end of file diff --git a/example/newClient.ts b/example/newClient.ts index e69de29..913549e 100644 --- a/example/newClient.ts +++ b/example/newClient.ts @@ -0,0 +1,17 @@ +import { io } from 'socket.io-client'; + +const main = async () => { + const socket = io('http://localhost:3000'); + + socket.on('connect', () => { + socket.emit('subscribe', 'SOL-PERP'); + }); + + socket.on('SOL-PERP', (data: any) => { + console.log(data); + }); +}; + +main().then(() => { + console.log('running'); +}); diff --git a/src/dlob-subscriber/DLOBSubscriberIO.ts b/src/dlob-subscriber/DLOBSubscriberIO.ts index fac3149..f0d4682 100644 --- a/src/dlob-subscriber/DLOBSubscriberIO.ts +++ b/src/dlob-subscriber/DLOBSubscriberIO.ts @@ -86,12 +86,11 @@ export class DLOBSubscriberIO extends DLOBSubscriber { } if ( - l2Args.updateOnChange && - this.lastSeenL2Formatted - .get(l2Args.marketType) - ?.get(l2Args.marketIndex) === JSON.stringify(l2Formatted) + l2Args.updateOnChange ) { - return; + if (this.lastSeenL2Formatted + .get(l2Args.marketType) + ?.get(l2Args.marketIndex) === JSON.stringify(l2Formatted)) return; } this.lastSeenL2Formatted .get(l2Args.marketType) diff --git a/src/wsConnectionManager.ts b/src/wsConnectionManager.ts index 9734f80..e5120ac 100644 --- a/src/wsConnectionManager.ts +++ b/src/wsConnectionManager.ts @@ -23,7 +23,6 @@ async function main() { console.log('Subscribing to channel', channel); redisClient.client.subscribe(channel); redisClient.client.on('message', (subscribedChannel, message) => { - console.log(message); if (subscribedChannel === channel) { socket.emit(channel, JSON.parse(message)); }