fix connection recreation which breaks EC lk connection
This commit is contained in:
@@ -110,20 +110,6 @@ export function createConnectionManager$({
|
|||||||
const logger = parentLogger.getChild("[ConnectionManager]");
|
const logger = parentLogger.getChild("[ConnectionManager]");
|
||||||
// TODO logger: only construct one logger from the client and make it compatible via a EC specific sing
|
// TODO logger: only construct one logger from the client and make it compatible via a EC specific sing
|
||||||
|
|
||||||
const allInputTransports$ = combineLatest([
|
|
||||||
localTransport$,
|
|
||||||
remoteTransports$,
|
|
||||||
]).pipe(
|
|
||||||
map(([localTransport, transports]) => {
|
|
||||||
const localTransportAsArray = localTransport ? [localTransport] : [];
|
|
||||||
return transports.mapInner((transports) => [
|
|
||||||
...localTransportAsArray,
|
|
||||||
...transports,
|
|
||||||
]);
|
|
||||||
}),
|
|
||||||
map((transports) => transports.mapInner(removeDuplicateTransports)),
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All transports currently managed by the ConnectionManager.
|
* All transports currently managed by the ConnectionManager.
|
||||||
*
|
*
|
||||||
@@ -134,30 +120,38 @@ export function createConnectionManager$({
|
|||||||
*/
|
*/
|
||||||
const transportsWithJwtTag$ = scope.behavior(
|
const transportsWithJwtTag$ = scope.behavior(
|
||||||
combineLatest([
|
combineLatest([
|
||||||
allInputTransports$,
|
remoteTransports$,
|
||||||
localTransport$,
|
localTransport$,
|
||||||
forceOldJwtEndpointForLocalTransport$,
|
forceOldJwtEndpointForLocalTransport$,
|
||||||
]).pipe(
|
]).pipe(
|
||||||
|
// combine local and remote transports into one transport array
|
||||||
|
// and set the forceOldJwtEndpoint property on the local transport
|
||||||
map(
|
map(
|
||||||
([
|
([
|
||||||
transports,
|
remoteTransports,
|
||||||
localTransport,
|
localTransport,
|
||||||
forceOldJwtEndpointForLocalTransport,
|
forceOldJwtEndpointForLocalTransport,
|
||||||
]) => {
|
]) => {
|
||||||
// modify only the local transport with forceOldJwtEndpointForLocalTransport
|
let localTransportAsArray: (LivekitTransport & {
|
||||||
const index = transports.value.findIndex((t) =>
|
forceOldJwtEndpoint: boolean;
|
||||||
areLivekitTransportsEqual(localTransport, t),
|
})[] = [];
|
||||||
);
|
if (localTransport) {
|
||||||
if (index !== -1) {
|
localTransportAsArray = [
|
||||||
transports.value[index].forceOldJwtEndpoint =
|
{
|
||||||
forceOldJwtEndpointForLocalTransport;
|
...localTransport,
|
||||||
|
forceOldJwtEndpoint: forceOldJwtEndpointForLocalTransport,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
logger.trace(
|
return new Epoch(
|
||||||
`Managing transports: ${transports.value.map((t) => t.livekit_service_url).join(", ")}`,
|
removeDuplicateTransports([
|
||||||
|
...localTransportAsArray,
|
||||||
|
...remoteTransports.value,
|
||||||
|
]) as (LivekitTransport & {
|
||||||
|
forceOldJwtEndpoint?: boolean;
|
||||||
|
})[],
|
||||||
|
remoteTransports.epoch,
|
||||||
);
|
);
|
||||||
return transports as Epoch<
|
|
||||||
(LivekitTransport & { forceOldJwtEndpoint?: boolean })[]
|
|
||||||
>;
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -181,7 +175,9 @@ export function createConnectionManager$({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
(scope, _data$, serviceUrl, alias, forceOldJwtEndpoint) => {
|
(scope, _data$, serviceUrl, alias, forceOldJwtEndpoint) => {
|
||||||
logger.debug(`Creating connection to ${serviceUrl} (${alias})`);
|
logger.debug(
|
||||||
|
`Creating connection to ${serviceUrl} (${alias}, forceOldJwtEndpoint: ${forceOldJwtEndpoint})`,
|
||||||
|
);
|
||||||
const connection = connectionFactory.createConnection(
|
const connection = connectionFactory.createConnection(
|
||||||
{
|
{
|
||||||
type: "livekit",
|
type: "livekit",
|
||||||
|
|||||||
Reference in New Issue
Block a user