Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add close connection to a charge point method #53

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading