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
+14
-2
@@ -183,8 +183,17 @@ export class FluxerRevoice extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async join(channelId, _leaveIfEmpty = false) {
|
async join(channelId, _leaveIfEmpty = false) {
|
||||||
if (this.connections.has(channelId)) {
|
if (this.connections.has(channelId)) {
|
||||||
logger.player(`[FluxerRevoice] Already connected to ${channelId}, returning existing connection`);
|
const existing = this.connections.get(channelId);
|
||||||
return 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 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...`);
|
logger.player(`[FluxerRevoice] Joining channel ${channelId} via Fluxer gateway...`);
|
||||||
@@ -306,6 +315,9 @@ export class FluxerRevoice extends EventEmitter {
|
|||||||
room.on(RoomEvent.Disconnected, (reason) => {
|
room.on(RoomEvent.Disconnected, (reason) => {
|
||||||
logger.player(`[FluxerRevoice] Room disconnected: ${reason ?? "unknown"}`);
|
logger.player(`[FluxerRevoice] Room disconnected: ${reason ?? "unknown"}`);
|
||||||
connection._connected = false;
|
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");
|
connection.emit("disconnect");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user