Skip to content

Commit

Permalink
Add close connection to a charge point method (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
GianOrtiz authored Jun 10, 2024
1 parent 5a99cb0 commit f3cf185
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/modules/cs/index.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -89,6 +90,14 @@ public addConnectionListener(listener: ConnectionListener)
public async close(): Promise<void>
```

### closeConnection (method)

**Signature**

```ts
public async closeConnection(chargePointId: string): Promise<void>
```

### sendRequest (method)

**Signature**
Expand Down
5 changes: 5 additions & 0 deletions src/cs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ export default class CentralSystem {
return Promise.all([httpClosing, wsClosing]).then(() => { });
}

public async closeConnection(chargePointId: string): Promise<void> {
const connections = this.connections[chargePointId];
await Promise.all(connections.map((connection) => connection.close()));
}

sendRequest<V extends OCPPVersion, T extends CentralSystemAction>(args: CSSendRequestArgs<T, V>): EitherAsync<OCPPRequestError, Response<T, V>> {
return EitherAsync.fromPromise(async () => {
const { chargePointId, payload, action } = args;
Expand Down

0 comments on commit f3cf185

Please sign in to comment.