Fix publisher clean up! This is the acutal bug we chased
This commit is contained in:
@@ -527,7 +527,10 @@ export function createCallViewModel$(
|
|||||||
connectOptions$.value,
|
connectOptions$.value,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
createPublisherFactory: (connection: Connection) => {
|
createPublisherFactory: (
|
||||||
|
scope: ObservableScope,
|
||||||
|
connection: Connection,
|
||||||
|
) => {
|
||||||
return new Publisher(
|
return new Publisher(
|
||||||
scope,
|
scope,
|
||||||
connection,
|
connection,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/En
|
|||||||
|
|
||||||
import { type Behavior } from "../../Behavior.ts";
|
import { type Behavior } from "../../Behavior.ts";
|
||||||
import { type IConnectionManager } from "../remoteMembers/ConnectionManager.ts";
|
import { type IConnectionManager } from "../remoteMembers/ConnectionManager.ts";
|
||||||
import { type ObservableScope } from "../../ObservableScope.ts";
|
import { ObservableScope } from "../../ObservableScope.ts";
|
||||||
import { type Publisher } from "./Publisher.ts";
|
import { type Publisher } from "./Publisher.ts";
|
||||||
import { type MuteStates } from "../../MuteStates.ts";
|
import { type MuteStates } from "../../MuteStates.ts";
|
||||||
import {
|
import {
|
||||||
@@ -124,7 +124,10 @@ interface Props {
|
|||||||
scope: ObservableScope;
|
scope: ObservableScope;
|
||||||
muteStates: MuteStates;
|
muteStates: MuteStates;
|
||||||
connectionManager: IConnectionManager;
|
connectionManager: IConnectionManager;
|
||||||
createPublisherFactory: (connection: Connection) => Publisher;
|
createPublisherFactory: (
|
||||||
|
scope: ObservableScope,
|
||||||
|
connection: Connection,
|
||||||
|
) => Publisher;
|
||||||
joinMatrixRTC: (transport: LivekitTransport) => void;
|
joinMatrixRTC: (transport: LivekitTransport) => void;
|
||||||
homeserverConnected: HomeserverConnected;
|
homeserverConnected: HomeserverConnected;
|
||||||
localTransport$: Behavior<LocalTransportWithSFUConfig | null>;
|
localTransport$: Behavior<LocalTransportWithSFUConfig | null>;
|
||||||
@@ -310,13 +313,18 @@ export const createLocalMembership$ = ({
|
|||||||
// - destruct all current streams
|
// - destruct all current streams
|
||||||
// - overwrite current publisher
|
// - overwrite current publisher
|
||||||
scope.reconcile(localConnection$, async (connection) => {
|
scope.reconcile(localConnection$, async (connection) => {
|
||||||
|
logger.info(
|
||||||
|
"reconcile based on new localConnection:",
|
||||||
|
connection?.transport.livekit_service_url,
|
||||||
|
);
|
||||||
if (connection !== null) {
|
if (connection !== null) {
|
||||||
const publisher = createPublisherFactory(connection);
|
const scope = new ObservableScope();
|
||||||
|
const publisher = createPublisherFactory(scope, connection);
|
||||||
publisher$.next(publisher);
|
publisher$.next(publisher);
|
||||||
// Clean-up callback
|
// Clean-up callback
|
||||||
|
|
||||||
return Promise.resolve(async (): Promise<void> => {
|
return Promise.resolve(async (): Promise<void> => {
|
||||||
await publisher.stopPublishing();
|
scope.end();
|
||||||
await publisher.stopTracks();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user