repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps): apply updates
[e-mobility-charging-stations-simulator.git]
/
ui
/
web
/
src
/
composables
/
UIClient.ts
diff --git
a/ui/web/src/composables/UIClient.ts
b/ui/web/src/composables/UIClient.ts
index ccd16c215565855d99ec0fa400bb7da0f8dd89bc..a474c8db5e66619f6e6d753a9241acfdfa9ed781 100644
(file)
--- a/
ui/web/src/composables/UIClient.ts
+++ b/
ui/web/src/composables/UIClient.ts
@@
-14,7
+14,7
@@
type ResponseHandler = {
reject: (reason?: unknown) => void;
};
reject: (reason?: unknown) => void;
};
-export
default
class UIClient {
+export class UIClient {
private static instance: UIClient | null = null;
private ws!: WebSocket;
private static instance: UIClient | null = null;
private ws!: WebSocket;
@@
-71,7
+71,7
@@
export default class UIClient {
public async startTransaction(
hashId: string,
connectorId: number,
public async startTransaction(
hashId: string,
connectorId: number,
- idTag: string | undefined
+ idTag: string | undefined
,
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.START_TRANSACTION, {
hashIds: [hashId],
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.START_TRANSACTION, {
hashIds: [hashId],
@@
-82,7
+82,7
@@
export default class UIClient {
public async stopTransaction(
hashId: string,
public async stopTransaction(
hashId: string,
- transactionId: number | undefined
+ transactionId: number | undefined
,
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.STOP_TRANSACTION, {
hashIds: [hashId],
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.STOP_TRANSACTION, {
hashIds: [hashId],
@@
-92,7
+92,7
@@
export default class UIClient {
public async startAutomaticTransactionGenerator(
hashId: string,
public async startAutomaticTransactionGenerator(
hashId: string,
- connectorId: number
+ connectorId: number
,
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, {
hashIds: [hashId],
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, {
hashIds: [hashId],
@@
-102,7
+102,7
@@
export default class UIClient {
public async stopAutomaticTransactionGenerator(
hashId: string,
public async stopAutomaticTransactionGenerator(
hashId: string,
- connectorId: number
+ connectorId: number
,
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, {
hashIds: [hashId],
): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, {
hashIds: [hashId],
@@
-113,7
+113,7
@@
export default class UIClient {
private openWS(): void {
this.ws = new WebSocket(
`ws://${config.uiServer.host}:${config.uiServer.port}`,
private openWS(): void {
this.ws = new WebSocket(
`ws://${config.uiServer.host}:${config.uiServer.port}`,
- config.uiServer.protocol
+ config.uiServer.protocol
,
);
this.ws.onmessage = this.responseHandler.bind(this);
this.ws.onerror = (errorEvent) => {
);
this.ws.onmessage = this.responseHandler.bind(this);
this.ws.onerror = (errorEvent) => {
@@
-128,7
+128,7
@@
export default class UIClient {
id: string,
procedureName: ProcedureName,
resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void,
id: string,
procedureName: ProcedureName,
resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void,
- reject: (reason?: unknown) => void
+ reject: (reason?: unknown) => void
,
): void {
this.responseHandlers.set(id, { procedureName, resolve, reject });
}
): void {
this.responseHandlers.set(id, { procedureName, resolve, reject });
}
@@
-143,11
+143,11
@@
export default class UIClient {
private async sendRequest(
command: ProcedureName,
private async sendRequest(
command: ProcedureName,
- data: RequestPayload
+ data: RequestPayload
,
): Promise<ResponsePayload> {
let uuid: string;
return promiseWithTimeout(
): Promise<ResponsePayload> {
let uuid: string;
return promiseWithTimeout(
- new Promise((resolve, reject) => {
+ new Promise
<ResponsePayload>
((resolve, reject) => {
uuid = crypto.randomUUID();
const msg = JSON.stringify([uuid, command, data]);
uuid = crypto.randomUUID();
const msg = JSON.stringify([uuid, command, data]);
@@
-166,7
+166,7
@@
export default class UIClient {
Error(`Send request '${command}' message timeout`),
() => {
this.responseHandlers.delete(uuid);
Error(`Send request '${command}' message timeout`),
() => {
this.responseHandlers.delete(uuid);
- }
+ }
,
);
}
);
}