Skip to content

Commit

Permalink
Dev 1.6.0-dev.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Oct 13, 2024
1 parent 0ebfc01 commit b8e56b6
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/matterbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,19 +1169,22 @@ export class Matterbridge extends EventEmitter {
this.httpServer = undefined;
this.log.debug('Frontend http server closed successfully');
}

// Close the https server
if (this.httpsServer) {
this.httpsServer.close();
this.httpsServer.removeAllListeners();
this.httpsServer = undefined;
this.log.debug('Frontend https server closed successfully');
}

// Remove listeners from the express app
if (this.expressApp) {
this.expressApp.removeAllListeners();
this.expressApp = undefined;
this.log.debug('Frontend app closed successfully');
}

// Close the WebSocket server
if (this.webSocketServer) {
// Close all active connections
Expand Down Expand Up @@ -1500,8 +1503,7 @@ export class Matterbridge extends EventEmitter {
this.startMatterInterval = undefined;
this.log.debug('Cleared startMatterInterval interval for Matterbridge');

await this.startMatterServer();
this.log.notice('Matter server started');
await this.runBridge();

// Configure the plugins
this.configureTimeout = setTimeout(async () => {
Expand All @@ -1516,9 +1518,6 @@ export class Matterbridge extends EventEmitter {
}
}, 30 * 1000);

// Show the QR code for commissioning or log the already commissioned message
await this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, this.nodeContext, 'Matterbridge');

// Setting reachability to true
this.reachabilityTimeout = setTimeout(() => {
this.log.info(`Setting reachability to true for ${plg}Matterbridge${db}`);
Expand All @@ -1528,6 +1527,15 @@ export class Matterbridge extends EventEmitter {
}, 1000);
}

protected async runBridge(): Promise<void> {
// Start the Matter server
await this.startMatterServer();
this.log.notice('Matter server started');

// Show the QR code for commissioning or log the already commissioned message
await this.showCommissioningQRCode(this.commissioningServer, this.matterbridgeContext, this.nodeContext, 'Matterbridge');
}

/**
* Initializes the child bridge.
*
Expand Down Expand Up @@ -1589,8 +1597,7 @@ export class Matterbridge extends EventEmitter {
this.startMatterInterval = undefined;
this.log.debug('Cleared startMatterInterval interval in childbridge mode');

await this.startMatterServer();
this.log.notice('Matter server started');
await this.runChildbridge();

// Configure the plugins
this.configureTimeout = setTimeout(async () => {
Expand Down Expand Up @@ -1636,6 +1643,12 @@ export class Matterbridge extends EventEmitter {
}, 1000);
}

protected async runChildbridge(): Promise<void> {
// Start the Matter server
await this.startMatterServer();
this.log.notice('Matter server started');
}

/**
* Starts the Matterbridge controller.
* @private
Expand Down

0 comments on commit b8e56b6

Please sign in to comment.