feat(v4.1.8): introduce dedicated WebsocketAPIClient

This commit is contained in:
tiagosiebler
2025-05-22 11:42:33 +01:00
parent c080f91f9b
commit 55fbf71e05
7 changed files with 117 additions and 80 deletions

View File

@@ -379,11 +379,13 @@ export class WebsocketClient extends BaseWebsocketClient<
await this.assertIsAuthenticated(wsKey);
this.logger.trace('sendWSAPIRequest()->assertIsAuthenticated() ok');
const timestampMs = Date.now() + (this.getTimeOffsetMs() || 0);
const requestEvent: WSAPIRequest<TWSParams> = {
reqId: this.getNewRequestId(),
header: {
'X-BAPI-RECV-WINDOW': `${this.options.recvWindow}`,
'X-BAPI-TIMESTAMP': `${Date.now()}`,
'X-BAPI-TIMESTAMP': `${timestampMs}`,
Referer: APIID,
},
op: operation,
@@ -415,7 +417,11 @@ export class WebsocketClient extends BaseWebsocketClient<
})
.catch((e) => {
if (typeof e === 'string') {
this.logger.error('unexpcted string', { e });
this.logger.error('Unexpected string thrown without Error object:', {
e,
wsKey,
signedEvent,
});
return e;
}
e.request = {