Skip to content

Commit

Permalink
update socket restart logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kajgm committed Nov 7, 2024
1 parent 92582a7 commit 045137a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 2 additions & 0 deletions client/src/crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export function coinbaseConnect() {

socket.onclose = (e) => {
console.log(e);
const newSocket = coinbaseConnect();
tickerStore.setSocket(newSocket);
};

socket.onerror = (err) => {
Expand Down
3 changes: 0 additions & 3 deletions client/src/server/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import { useTickerStore } from '@/store/ticker.js';
import { coinbaseConnect } from '@/crypto/crypto.js';
import { fmpQuery } from '@/stock/stock.js';

const SERVER_TIMEOUT = 1000;
Expand Down Expand Up @@ -59,8 +58,6 @@ export function pollUpdatedTickers() {

if (tickerStore.cryptoSocket && tickerStore.cryptoStatus == 'UPDATED') {
tickerStore.cryptoSocket.close();
const newSocket = coinbaseConnect();
tickerStore.setSocket(newSocket);
}

if (tickerStore.stockStatus == 'UPDATED') {
Expand Down

0 comments on commit 045137a

Please sign in to comment.