X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ui%2Fweb%2Fsrc%2Fcomposables%2FUIClient.ts;h=387d73d27529bfaf91e25f068bd9612ce53fb33c;hb=de7b9e0583275225509c099f75a2801371da54d0;hp=841ec3dca8c42510c3ce504c05dbe42c45773adc;hpb=82fa111074a9a4eed94579c0ff734a1564f8f8e6;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index 841ec3dc..387d73d2 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -144,15 +144,13 @@ export class UIClient { command: ProcedureName, data: RequestPayload, ): Promise { - let uuid: string; - return await new Promise((resolve, reject) => { - uuid = crypto.randomUUID(); - const msg = JSON.stringify([uuid, command, data]); - + return new Promise((resolve, reject) => { if (this.ws.readyState !== WebSocket.OPEN) { this.openWS(); } if (this.ws.readyState === WebSocket.OPEN) { + const uuid = crypto.randomUUID(); + const msg = JSON.stringify([uuid, command, data]); const sendTimeout = setTimeout(() => { this.deleteResponseHandler(uuid); return reject(new Error(`Send request '${command}' message timeout`));