libshv-js 3.12.1 → 3.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ws-client.ts +4 -5
package/package.json
CHANGED
package/src/ws-client.ts
CHANGED
|
@@ -187,7 +187,7 @@ class WsClient {
|
|
|
187
187
|
delayCallback?: (progress: number) => void;
|
|
188
188
|
timeout_handle: ReturnType<typeof globalThis.setTimeout>;
|
|
189
189
|
}> = [];
|
|
190
|
-
private requestHandlers
|
|
190
|
+
private requestHandlers = new Map<number, RequestHandler>();
|
|
191
191
|
private abortedRequests = new Set<number>();
|
|
192
192
|
private readonly subscriptions: Subscription[] = [];
|
|
193
193
|
private readonly websocket: WebSocket;
|
|
@@ -236,7 +236,7 @@ class WsClient {
|
|
|
236
236
|
};
|
|
237
237
|
|
|
238
238
|
if (RPC_MESSAGE_ABORT in request.value) {
|
|
239
|
-
const requestHandler = this.requestHandlers
|
|
239
|
+
const requestHandler = this.requestHandlers.get(requestId);
|
|
240
240
|
|
|
241
241
|
if (request.value[RPC_MESSAGE_ABORT] === true && requestHandler?.options.onAbort !== undefined) {
|
|
242
242
|
this.abortedRequests.add(requestId);
|
|
@@ -254,7 +254,7 @@ class WsClient {
|
|
|
254
254
|
try {
|
|
255
255
|
let result = this.options.onRequest(request.meta[RPC_MESSAGE_SHV_PATH], request.meta[RPC_MESSAGE_METHOD], request.value[RPC_MESSAGE_PARAMS], sendDelay);
|
|
256
256
|
if (result instanceof RequestHandler) {
|
|
257
|
-
this.requestHandlers
|
|
257
|
+
this.requestHandlers.set(requestId, result);
|
|
258
258
|
result = result.options.result;
|
|
259
259
|
}
|
|
260
260
|
|
|
@@ -269,8 +269,7 @@ class WsClient {
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
if (requestId in this.requestHandlers) {
|
|
272
|
-
|
|
273
|
-
delete this.requestHandlers[requestId];
|
|
272
|
+
this.requestHandlers.delete(requestId);
|
|
274
273
|
}
|
|
275
274
|
} catch (error: unknown) {
|
|
276
275
|
const sendError = (error: RpcError) => {
|