From fe1c320081508542b07537137eac032cacaa8ae5 Mon Sep 17 00:00:00 2001 From: nwaschk Date: Mon, 23 Jun 2025 18:46:31 +0200 Subject: [PATCH] Optimierung des pdr2 request flows --- src/electron/pdr2com/connection.ts | 6 +++++- src/electron/pdr2com/wrapper.ts | 30 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/electron/pdr2com/connection.ts b/src/electron/pdr2com/connection.ts index 9e0cdfb..9bd9cac 100644 --- a/src/electron/pdr2com/connection.ts +++ b/src/electron/pdr2com/connection.ts @@ -54,7 +54,11 @@ export class ProdressConnection { // Sends the writes and sends the request when the connecting is established this.socket.once('connect', () => { try { - this.request.writeEntries(this.requestBody); + // sets the flag for awaiting a response to true + this.request.writeEntry(['integer', 1]); + // writes the body in to the request + this.request.writeBody(this.requestBody); + // sends the request this.request.sende(this.socket); } catch (error) { response = stringifyError(error as Error); diff --git a/src/electron/pdr2com/wrapper.ts b/src/electron/pdr2com/wrapper.ts index dac5953..3fdd3d1 100644 --- a/src/electron/pdr2com/wrapper.ts +++ b/src/electron/pdr2com/wrapper.ts @@ -26,23 +26,27 @@ export class ProdressRequest extends Request { } /** - * writes entries based on the provided requestTupelList into the request + * writes the provided body into the request * @param requestBody */ - public writeEntries(requestBody: Pdr2_RequestBody): void { - // write additionalInformation - for (const tupel of requestBody.additionalInformation) { - this.writeEntry(tupel); - } - - // write amount of argument entries + public writeBody(requestBody: Pdr2_RequestBody): void { + // writes additional information into the request + this.writeEntries(requestBody.additionalInformation); + // writes the amount of upcoming entries into the request this.writeEntry(['integer', requestBody.arguments.length]); - - // write arguments + // writes the data entries into the request for (const args of requestBody.arguments) { - for (const tupel of args) { - this.writeEntry(tupel); - } + this.writeEntries(args); + } + } + + /** + * writes entries based on the provided requestTupelList into the request + * @param requestTupelList + */ + public writeEntries(requestTupelList: Pdr2_RequestTupel[]): void { + for (const tupel of requestTupelList) { + this.writeEntry(tupel); } }