re-establish subscriptions after ws disconnect

This commit is contained in:
tim
2025-02-26 17:28:23 -04:00
parent 2e49346533
commit f5f53c6af4
3 changed files with 16 additions and 2 deletions

View File

@@ -17,6 +17,16 @@ export function subOHLC( chainId, pool, period ) {
} }
export function refreshOHLCSubs() {
const keys = []
for (const key of Object.keys(ohlcSubCounts)) {
const [chainId, pool, period] = key.split('|')
keys.push(`${pool}|${period}`)
}
socket.emit('subOHLCs', chainId, keys)
}
export function unsubOHLC( chainId, pool, period ) { export function unsubOHLC( chainId, pool, period ) {
const key = `${pool}|${period}` const key = `${pool}|${period}`
const ckey = `${chainId}|${key}` const ckey = `${chainId}|${key}`

View File

@@ -318,7 +318,6 @@ const orders = computed(()=>{
st.id = `${vault}|${index}` st.id = `${vault}|${index}`
st.index = parseInt(index) st.index = parseInt(index)
// st.startTime = timestampString(st.startTime) // st.startTime = timestampString(st.startTime)
console.log('starttime', st.startTime)
/* /*
o.tranches = o.tranches.map((tranche)=>{ o.tranches = o.tranches.map((tranche)=>{
const t = {...tranche} const t = {...tranche}

View File

@@ -4,12 +4,17 @@ import {flushOrders} from "@/blockchain/wallet.js";
import {parseElaboratedOrderStatus} from "@/blockchain/orderlib.js"; import {parseElaboratedOrderStatus} from "@/blockchain/orderlib.js";
import { DataFeed } from "./charts/datafeed"; import { DataFeed } from "./charts/datafeed";
import {notifyFillEvent} from "@/notify.js"; import {notifyFillEvent} from "@/notify.js";
import {refreshOHLCSubs} from "@/blockchain/ohlcs.js";
export const socket = io(import.meta.env.VITE_WS_URL || undefined, {transports: ["websocket"]}) export const socket = io(import.meta.env.VITE_WS_URL || undefined, {transports: ["websocket"]})
socket.on('connect', () => { socket.on('connect', () => {
console.log(new Date(), 'ws connected') console.log(new Date(), 'ws connected')
useStore().connected = true const s = useStore();
s.connected = true
if (s.chainId && s.account)
socket.emit('address', s.chainId, s.account)
refreshOHLCSubs()
}) })
socket.on('disconnect', () => { socket.on('disconnect', () => {