Adds ReactEventEmitter and full handling of broadcastStarted event

This commit is contained in:
Tiago Jacobs
2022-03-11 19:55:12 -03:00
parent 3c17cd7aed
commit a4ce10b000
52 changed files with 1737 additions and 1579 deletions

View File

@@ -0,0 +1,36 @@
import { initializeScreenShare as nativeInitializeScreenShare } from '../native-components/BBBN_ScreenShareService';
import nativeEmitter from '../native-messaging/emitter';
// Reference to the resolver of last call
let resolve = (a: String) => {
console.log(
`default resolve function called, this should never happen: ${a}`
);
};
// Log a message when broadcast is requested
nativeEmitter.addListener('onBroadcastRequested', () => {
console.log(`Broadcast requested`);
});
// Resolve promise when broadcast is started (this event means that user confirmed the screenshare)
nativeEmitter.addListener('onBroadcastStarted', () => {
resolve('null');
});
// Entry point of this method
function initializeScreenShare() {
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
nativeInitializeScreenShare();
} catch (e) {
rej(`Call to nativeInitializeScreenShare failed`);
}
});
}
export default initializeScreenShare;