refactor: improve shutdown cleanup

This commit is contained in:
Carlos Valente
2026-03-13 22:52:18 +01:00
committed by Carlos Valente
parent 871a6b46c8
commit 4408bdb0d3
5 changed files with 135 additions and 30 deletions
+9 -2
View File
@@ -72,10 +72,17 @@ class OscServer implements IAdapter {
});
this.udpSocket.bind(port);
}
shutdown() {
shutdown(): Promise<void> {
logger.info(LogOrigin.Rx, 'OSC: Closing server');
this.udpSocket?.close();
const socket = this.udpSocket;
this.udpSocket = null;
if (!socket) {
return Promise.resolve();
}
return new Promise((resolve) => {
socket.close(() => resolve());
});
}
}