Add setRemoteSDP method

This commit is contained in:
Tiago Jacobs
2022-03-27 15:05:47 -03:00
parent ce5b8e8979
commit 6fce1d61f3
13 changed files with 131 additions and 14 deletions

View File

@@ -0,0 +1,32 @@
import { setScreenShareRemoteSDP as nativeSetScreenShareRemoteSDP } from '../native-components/BBBN_ScreenShareService';
import nativeEmitter from '../native-messaging/emitter';
// Reference to the resolver of last call
let resolve = (value: unknown) => {
console.log(
`default resolve function called, this should never happen: ${value}`
);
};
// Resolve promise when SDP offer is available
nativeEmitter.addListener('onSetScreenShareRemoteSDPCompleted', () => {
resolve(undefined);
});
// Entry point of this method
function setScreenShareRemoteSDP(remoteSdp: string) {
return new Promise((res, rej) => {
// store the resolver for later call (when event is received)
resolve = res;
try {
console.log(`>nativeSetScreenShareRemoteSDP ${remoteSdp}`);
// call native swift method that triggers the broadcast popup
nativeSetScreenShareRemoteSDP(remoteSdp);
} catch (e) {
rej(`Call to nativeSetScreenShareRemoteSDP failed`);
}
});
}
export default setScreenShareRemoteSDP;