stopping brodcast extension on click to stop screen share
This commit is contained in:
32
src/methods/stopScreenShare.tsx
Normal file
32
src/methods/stopScreenShare.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { stopScreenShareBroadcastExtension as nativeStopScreenShare } from '../native-components/BBBN_ScreenShareService';
|
||||
import nativeEmitter from '../native-messaging/emitter';
|
||||
|
||||
// Reference to the resolver of last call
|
||||
let resolve = (a: String | null) => {
|
||||
console.log(
|
||||
`default resolve function called, this should never happen: ${a}`
|
||||
);
|
||||
};
|
||||
|
||||
// Resolve promise when broadcast is started (this event means that user confirmed the screenshare)
|
||||
nativeEmitter.addListener('onBroadcastFinished', () => {
|
||||
resolve(null);
|
||||
});
|
||||
|
||||
// Entry point of this method
|
||||
function stopScreenShare(instanceId: Number) {
|
||||
return new Promise((res, rej) => {
|
||||
// store the resolver for later call (when event is received)
|
||||
resolve = res;
|
||||
|
||||
try {
|
||||
// call native swift method that triggers the broadcast popup
|
||||
console.log(`[${instanceId}] - >stopScreenShare`);
|
||||
nativeStopScreenShare();
|
||||
} catch (e) {
|
||||
rej(`Call to stopScreenShare failed zzy`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default stopScreenShare;
|
||||
@@ -17,3 +17,7 @@ export function setScreenShareRemoteSDP(remoteSDP: string) {
|
||||
export function addScreenShareRemoteIceCandidate(remoteCandidateJson: string) {
|
||||
ScreenShareService.addScreenShareRemoteIceCandidate(remoteCandidateJson);
|
||||
}
|
||||
|
||||
export function stopScreenShareBroadcastExtension() {
|
||||
ScreenShareService.stopScreenShareBroadcastExtension();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import setScreenShareRemoteSDP from '../methods/setScreenShareRemoteSDP';
|
||||
import setFullAudioRemoteSDP from '../methods/setFullAudioRemoteSDP';
|
||||
import addScreenShareRemoteIceCandidate from '../methods/addScreenShareRemoteIceCandidate';
|
||||
import createFullAudioOffer from '../methods/createFullAudioOffer';
|
||||
import stopScreenShare from '../methods/stopScreenShare';
|
||||
|
||||
function observePromiseResult(
|
||||
instanceId: Number,
|
||||
@@ -66,6 +67,9 @@ export function handleWebviewMessage(
|
||||
JSON.stringify(data?.arguments[0])
|
||||
);
|
||||
break;
|
||||
case 'stopScreenShare':
|
||||
promise = stopScreenShare(instanceId)
|
||||
break;
|
||||
default:
|
||||
throw `[${instanceId}] - Unknown method ${data?.method}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user