From 2ee976eaace15b627cf4e73d56ef6f38acf3d614 Mon Sep 17 00:00:00 2001 From: Gian Ortiz Date: Fri, 7 Jun 2024 18:04:52 -0300 Subject: [PATCH] Add close connection to a charge point method --- docs/modules/cs/index.ts.md | 9 +++++++++ src/cs/index.ts | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/docs/modules/cs/index.ts.md b/docs/modules/cs/index.ts.md index e27c37c..5e3fccc 100644 --- a/docs/modules/cs/index.ts.md +++ b/docs/modules/cs/index.ts.md @@ -17,6 +17,7 @@ Sets up a central system, that can communicate with charge points - [getConnectedChargePoints (method)](#getconnectedchargepoints-method) - [addConnectionListener (method)](#addconnectionlistener-method) - [close (method)](#close-method) + - [closeConnection (method)](#closeconnection-method) - [sendRequest (method)](#sendrequest-method) - [utils](#utils) - [CSSendRequestArgs (type alias)](#cssendrequestargs-type-alias) @@ -89,6 +90,14 @@ public addConnectionListener(listener: ConnectionListener) public async close(): Promise ``` +### closeConnection (method) + +**Signature** + +```ts +public async closeConnection(chargePointId: string): Promise +``` + ### sendRequest (method) **Signature** diff --git a/src/cs/index.ts b/src/cs/index.ts index b57cd19..dcd6f06 100644 --- a/src/cs/index.ts +++ b/src/cs/index.ts @@ -163,6 +163,11 @@ export default class CentralSystem { return Promise.all([httpClosing, wsClosing]).then(() => { }); } + public async closeConnection(chargePointId: string): Promise { + const connections = this.connections[chargePointId]; + await Promise.all(connections.map((connection) => connection.close())); + } + sendRequest(args: CSSendRequestArgs): EitherAsync> { return EitherAsync.fromPromise(async () => { const { chargePointId, payload, action } = args;