Skip to content

Commit

Permalink
Merge pull request #13 from drift-labs/master
Browse files Browse the repository at this point in the history
improvements
  • Loading branch information
NourAlharithi authored Nov 10, 2023
2 parents 180d8fc + 384e785 commit 5932037
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"license": "Apache-2.0",
"dependencies": {
"@drift-labs/sdk": "2.43.0-beta.10",
"@drift-labs/sdk": "2.43.0-beta.14",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
"@opentelemetry/exporter-prometheus": "^0.31.0",
Expand Down
12 changes: 11 additions & 1 deletion src/wsConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ async function main() {
const channelSubscribers = new Map<string, Set<WebSocket>>();
const subscribedChannels = new Set<string>();

redisClient.client.on('connect', () => {
subscribedChannels.forEach(async (channel) => {
try {
await redisClient.client.subscribe(channel);
} catch (error) {
console.error(`Error subscribing to ${channel}:`, error);
}
});
});

redisClient.client.on('message', (subscribedChannel, message) => {
const subscribers = channelSubscribers.get(subscribedChannel);
subscribers.forEach((ws) => {
Expand Down Expand Up @@ -132,7 +142,6 @@ async function main() {

// Listen for pong messages
ws.on('pong', () => {
console.log('poooooooong');
isAlive = true;
clearTimeout(pongTimeoutId);
});
Expand All @@ -146,6 +155,7 @@ async function main() {
if (subscribers.delete(ws) && subscribers.size === 0) {
redisClient.client.unsubscribe(channel);
channelSubscribers.delete(channel);
subscribedChannels.delete(channel);
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@
enabled "2.0.x"
kuler "^2.0.0"

"@drift-labs/[email protected].10":
version "2.43.0-beta.10"
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.43.0-beta.10.tgz#afe05e7b6aaf557d495a2e4743767be4b6c27435"
integrity sha512-NqQ2jV7ewiAkL2nNdxnoi1C+tefnxskFo9rHtl6yUF6NpygE08usOcbCu5to+Cyrtx6cSAymHsxCrDU1c7lkQw==
"@drift-labs/[email protected].14":
version "2.43.0-beta.14"
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.43.0-beta.14.tgz#0cd2ada9cda91519d341d7963ad7d18f6d3f1dff"
integrity sha512-9o+zbpBo0U5nRxcspobV2J4vYGssJaJRvOCOHYql/bnlzXd8qweXg3zRZI2XD1T9vQX4Si12DW5Hw5+jsxIsuw==
dependencies:
"@coral-xyz/anchor" "0.28.1-beta.2"
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
Expand Down

0 comments on commit 5932037

Please sign in to comment.