Skip to content

Instantly share code, notes, and snippets.

@cpv123
Last active August 17, 2020 03:04
Show Gist options
  • Save cpv123/5ee56acb4d03f4324f16df72463e69e8 to your computer and use it in GitHub Desktop.
Save cpv123/5ee56acb4d03f4324f16df72463e69e8 to your computer and use it in GitHub Desktop.
class JitsiView extends React.Component {
componentDidMount() {
this.initJitsi();
}
componentWillUnmount() {
if (this.api) {
this.api.dispose();
}
}
initiJitsi = () => {
const { roomConfig, userConfig } = this.props;
// Prepare config for the Jitsi Meet API
const options = {
roomName: roomConfig.name,
parentNode: document.querySelector('#jitsi-mount'),
};
if (!window.JitsiMeetExternalAPI) {
global.error('JitsiMeetExternalAPI not found');
return;
}
this.api = new window.JitsiMeetExternalAPI(JITSI_DOMAIN, options);
this.api.addEventListener('videoConferenceJoined', () => {
// Give the user a display name that other participants will see
// and give the conference a subject for all to see
this.api.executeCommands({
displayName: userConfig.displayName,
subject: roomConfig.subject,
});
});
this.api.addEventListener('videoConferenceLeft', () => { ... });
};
render() {
return (
<JitsiViewWrapper>
<div id="jitsi-mount" />
</JitsiViewWrapper>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment