Skip to content

Commit

Permalink
rename web-assisted as web-guest
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoyse-apizee committed Oct 20, 2023
1 parent 090bd3b commit beec5a0
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions docs/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,41 @@
const domContainer = document.querySelector('#room-container');

const root = ReactDOM.createRoot(domContainer);
root.render(React.createElement(
ApiRtcMuiReactRoom.Room,
{
sx: {
height: '99vh',// to prevent vertical scrollbar on Chrome
width: '100vw',
maxWidth: '100%' // to prevent horizontal scrollbar on Chrome
},
name: conversationName,
credentials: { apiKey: apiKey },
//registerInformation: { cloudUrl: 'https://cloud.apirtc.com' },
onLeave: () => {
ReactDOM.unmountComponentAtNode(domContainer);
}

const properties = {
sx: {
height: '99vh',// to prevent vertical scrollbar on Chrome
width: '100vw',
maxWidth: '100%' // to prevent horizontal scrollbar on Chrome
},
name: conversationName,
credentials: { apiKey: apiKey },
//registerInformation: { cloudUrl: 'https://cloud.apirtc.com' },
onLeave: () => {
ReactDOM.unmountComponentAtNode(domContainer);
window.parent.postMessage({ type: 'onLeave' }, '*');
}
));
}

root.render(React.createElement(ApiRtcMuiReactRoom.Room, properties));

const a = document.getElementById('room-link');
a.href = `${window.location.origin}${window.location.pathname}?${API_KEY_SEARCH_PARAMETER}=${apiKey}&${CONVERSATION_NAME_SEARCH_PARAMETER}=${conversationName}`;

window.addEventListener(
"message",
(event) => {
const eventObject = JSON.parse(event.data);
console.log('iframe receives message:', eventObject);
//if (eventObject.origin !== "http://example.org:8080") return;

if (eventObject.type === 'changeName') {
console.log('changeName', eventObject.name)
properties.name = eventObject.name;
}
},
false
);
</script>

</body>
Expand Down

0 comments on commit beec5a0

Please sign in to comment.