Skip to content
Draft
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
6 changes: 6 additions & 0 deletions lib/utils/nodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class NodeManager<S extends BlueshellState, E> extends EventEmitter imple
private server: Websocket.Server|undefined;
// node inspection session
private session = new Session();
// websocket connections connected to the server
private connectionSockets: Websocket[] = [];
// singleton instance of the manager
private static instance: NodeManager<BlueshellState, any>|null = null;

Expand Down Expand Up @@ -84,6 +86,8 @@ export class NodeManager<S extends BlueshellState, E> extends EventEmitter imple

// setup the connection handler
this.server.on('connection', (clientSocket) => {
this.connectionSockets.push(clientSocket);

// send the current cached breakpoints to the client if the client reconnects
this.breakpointInfoMap.forEach((breakpointInfo) => {
breakpointInfo.breakpoints.forEach((breakpoint) => {
Expand Down Expand Up @@ -406,7 +410,9 @@ export class NodeManager<S extends BlueshellState, E> extends EventEmitter imple

// Shuts down the debug server
public async shutdown() {
this.session.disconnect();
if (this.server) {
this.connectionSockets.forEach((socket) => socket.close());
await util.promisify(this.server.close.bind(this.server));
}
}
Expand Down