INNER CODE UNIT · JavaScript
TradovateWsClient
dearvn/tradovate-trading-bot · agents/market-data/index.js:42
class TradovateWsClient {
constructor({ url, label, logger, onMessage }) {
this.url = url;
this.label = label;
this.logger = logger;
this.onMessage = onMessage;
this.ws = null;
this._requestCounter = 0;
this._heartbeatTimer = null;
this._destroyed = false;
}
_buildFrame(endpoint, query = '', body = null) {
const id = ++this._requestCounter;
const bodyStr = body !== null ? (typeof body === 'string' ? body : JSON.stringify(body)) : '';
return { id, frame: `${endpoint}\n${id}\n${query}\n${bodyStr}` };
}