fix(music-together): fix connection disconnect message

This commit is contained in:
JellyBrick
2025-05-12 06:31:37 +09:00
parent 3200d088cf
commit 98be48bb13

View File

@ -135,6 +135,11 @@ export class Connection {
if (this._mode === 'disconnected') throw new Error('Already disconnected'); if (this._mode === 'disconnected') throw new Error('Already disconnected');
this._mode = 'disconnected'; this._mode = 'disconnected';
this.getConnections().forEach((conn) =>
conn.close({
flush: true,
}),
);
this.connections = {}; this.connections = {};
this.connectionListeners = []; this.connectionListeners = [];
for (const listener of this.listeners) { for (const listener of this.listeners) {
@ -228,6 +233,9 @@ export class Connection {
this.connectionListeners.forEach((listener) => listener(conn)); this.connectionListeners.forEach((listener) => listener(conn));
if (err) { if (err) {
if (err.type === 'connection-closed') {
this.connectionListeners.forEach((listener) => listener());
}
reject(err); reject(err);
} }
}; };