From 95b23236e0420ab6f6f1ba8f7cb0e26a9fd4fea3 Mon Sep 17 00:00:00 2001 From: jakergrossman Date: Thu, 18 Nov 2021 00:38:07 -0600 Subject: [PATCH] Add clarification comment to send --- src/hubManager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hubManager.ts b/src/hubManager.ts index 694bc96..31fac9f 100644 --- a/src/hubManager.ts +++ b/src/hubManager.ts @@ -150,14 +150,18 @@ export default class HubManager { } /** - * Send an RPC message and get the corresponding response. + * Send an RPC message. The corresponding Promise resolve + * is saved into the `pendingRequests` map. When an inbound + * message is found that matches an ID in `pendingRequests`, + * the corresponding resolve is called. So, even though + * the `resolve` call does not appear explicitly here, it *does* + * get resolved at the appropriate time. * * @param `proc` Procedure to execute * @param `params` Optional parameters for the procedure * @param `id` The ID to use for the RPC message. Use null to indicate no ID/notification message. * If neither a string or `null` is passed, an ID is automatically generated. */ - // TODO: make send take a single RPCRequest argument, made inline in each function public async send(request: RPCRequest): Promise { return new Promise((resolve, reject) => { if (request['i'] === undefined) {