mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
test
This commit is contained in:
1 parent
5183f41862
commit
a3da50e11a
1 file changed
+13
-1
@@ -183,8 +183,17 @@ export class FluxerRevoice extends EventEmitter {
|
||||
*/
|
||||
async join(channelId, _leaveIfEmpty = false) {
|
||||
if (this.connections.has(channelId)) {
|
||||
const existing = this.connections.get(channelId);
|
||||
// If the existing connection is still alive, reuse it.
|
||||
// If the LiveKit room disconnected, the connection is stale — remove it
|
||||
// so we can create a fresh one instead of returning a dead connection
|
||||
// that will fail with "LiveKit disconnected (connectionState: 0)".
|
||||
if (existing && !existing._destroyed && existing.room && existing.room.isConnected) {
|
||||
logger.player(`[FluxerRevoice] Already connected to ${channelId}, returning existing connection`);
|
||||
return this.connections.get(channelId);
|
||||
return existing;
|
||||
}
|
||||
logger.player(`[FluxerRevoice] Stale connection for ${channelId} (isConnected: ${existing?.room?.isConnected ?? false}, destroyed: ${existing?._destroyed ?? true}) — removing and rejoining`);
|
||||
this.connections.delete(channelId);
|
||||
}
|
||||
|
||||
logger.player(`[FluxerRevoice] Joining channel ${channelId} via Fluxer gateway...`);
|
||||
@@ -306,6 +315,9 @@ export class FluxerRevoice extends EventEmitter {
|
||||
room.on(RoomEvent.Disconnected, (reason) => {
|
||||
logger.player(`[FluxerRevoice] Room disconnected: ${reason ?? "unknown"}`);
|
||||
connection._connected = false;
|
||||
// Remove from connections map so the next join() creates a fresh
|
||||
// connection instead of returning this dead one.
|
||||
this.connections.delete(channelId);
|
||||
connection.emit("disconnect");
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user