Add more granular leave/join api
This commit is contained in:
12
sdk/main.ts
12
sdk/main.ts
@@ -68,6 +68,12 @@ interface MatrixRTCSdk {
|
|||||||
join: () => void;
|
join: () => void;
|
||||||
/** @throws on leave errors */
|
/** @throws on leave errors */
|
||||||
leave: () => void;
|
leave: () => void;
|
||||||
|
/**
|
||||||
|
* Ends the rtc sdk. This will unsubscribe any event listeners. And end the associated scope.
|
||||||
|
* No updates can be received from the rtc sdk. The sdk cannot be restarted after.
|
||||||
|
* A new sdk needs to be created via createMatrixRTCSdk.
|
||||||
|
*/
|
||||||
|
stop: () => void;
|
||||||
data$: Observable<{ rtcBackendIdentity: string; data: string }>;
|
data$: Observable<{ rtcBackendIdentity: string; data: string }>;
|
||||||
/**
|
/**
|
||||||
* flattened list of members
|
* flattened list of members
|
||||||
@@ -290,9 +296,6 @@ export async function createMatrixRTCSdk(
|
|||||||
|
|
||||||
// schedule close first and then leave (scope.end)
|
// schedule close first and then leave (scope.end)
|
||||||
void scheduleWidgetCloseOnLeave();
|
void scheduleWidgetCloseOnLeave();
|
||||||
|
|
||||||
// actual hangup (ending scope will send the leave event.. its kinda odd. since you might end up closing the widget too fast)
|
|
||||||
scope.end();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("createMatrixRTCSdk done");
|
logger.info("createMatrixRTCSdk done");
|
||||||
@@ -305,8 +308,11 @@ export async function createMatrixRTCSdk(
|
|||||||
},
|
},
|
||||||
leave: (): void => {
|
leave: (): void => {
|
||||||
callViewModel.hangup();
|
callViewModel.hangup();
|
||||||
|
},
|
||||||
|
stop: (): void => {
|
||||||
leaveSubs.unsubscribe();
|
leaveSubs.unsubscribe();
|
||||||
livekitRoomItemsSub.unsubscribe();
|
livekitRoomItemsSub.unsubscribe();
|
||||||
|
scope.end();
|
||||||
},
|
},
|
||||||
data$,
|
data$,
|
||||||
localMember$: scope.behavior(
|
localMember$: scope.behavior(
|
||||||
|
|||||||
@@ -217,15 +217,23 @@ export interface CallViewModel {
|
|||||||
"unknown" | "ringing" | "timeout" | "decline" | "success" | null
|
"unknown" | "ringing" | "timeout" | "decline" | "success" | null
|
||||||
>;
|
>;
|
||||||
/** Observable that emits when the user should leave the call (hangup pressed, widget action, error).
|
/** Observable that emits when the user should leave the call (hangup pressed, widget action, error).
|
||||||
* THIS DOES NOT LEAVE THE CALL YET. The only way to leave the call (send the hangup event) is by ending the scope.
|
* THIS DOES NOT LEAVE THE CALL YET. The only way to leave the call (send the hangup event) is
|
||||||
|
* - by ending the scope
|
||||||
|
* - or calling requestDisconnect
|
||||||
|
*
|
||||||
|
* TODO: it seems more reasonable to add a leave() method (that calls requestDisconnect) that will then update leave$ and remove the hangup pattern
|
||||||
*/
|
*/
|
||||||
leave$: Observable<"user" | AutoLeaveReason>;
|
leave$: Observable<"user" | AutoLeaveReason>;
|
||||||
/** Call to initiate hangup. Use in conbination with reconnectino state track the async hangup process. */
|
/** Call to initiate hangup. Use in conbination with reconnection state track the async hangup process. */
|
||||||
hangup: () => void;
|
hangup: () => void;
|
||||||
|
|
||||||
// joining
|
// joining
|
||||||
join: () => void;
|
join: () => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calls requestDisconnect. The async leave state can than be observed via connected$
|
||||||
|
*/
|
||||||
|
leave: () => void;
|
||||||
// screen sharing
|
// screen sharing
|
||||||
/**
|
/**
|
||||||
* Callback to toggle screen sharing. If null, screen sharing is not possible.
|
* Callback to toggle screen sharing. If null, screen sharing is not possible.
|
||||||
@@ -1496,6 +1504,7 @@ export function createCallViewModel$(
|
|||||||
leave$: leave$,
|
leave$: leave$,
|
||||||
hangup: (): void => userHangup$.next(),
|
hangup: (): void => userHangup$.next(),
|
||||||
join: localMembership.requestJoinAndPublish,
|
join: localMembership.requestJoinAndPublish,
|
||||||
|
leave: localMembership.requestDisconnect,
|
||||||
toggleScreenSharing: toggleScreenSharing,
|
toggleScreenSharing: toggleScreenSharing,
|
||||||
sharingScreen$: sharingScreen$,
|
sharingScreen$: sharingScreen$,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user