Skip to content

Commit

Permalink
Merge pull request #49 from voltbras/closing-ws-connections-on-close-…
Browse files Browse the repository at this point in the history
…method

Closing ws connections on close method call
  • Loading branch information
leviermonaites authored Dec 19, 2023
2 parents 2314630 + a78a710 commit 61b012d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export default class CentralSystem {
this.listeners.push(listener);
}

public close(): Promise<void> {
public async close(): Promise<void> {
Object.values(this.connections).map((chargepointConnections) => {
chargepointConnections.map((connection) => {
connection.close();
});
})
const httpClosing = new Promise(resolve => this.httpServer.close(resolve));
const wsClosing = new Promise(resolve => this.websocketsServer.close(resolve));
return Promise.all([httpClosing, wsClosing]).then(() => { });
Expand Down Expand Up @@ -358,4 +363,4 @@ export default class CentralSystem {
this.listeners.forEach((f) => f(chargePointId, 'disconnected'));
});
}
}
}

0 comments on commit 61b012d

Please sign in to comment.