-
-
Save DanyF-github/f51ebb507f9acfd4f9bdb53876f6eb17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// client/src/components/Videocall/Room.tsx | |
import React from 'react'; | |
import { useQuery } from '@apollo/client'; | |
import { GET_START_CALL_SETTINGS } from '../../data/queries'; | |
import { OTSession, OTPublisher, OTStreams, OTSubscriber } from 'opentok-react'; | |
const Room = (props: any) => { | |
// get the uuid from props | |
const { uuid } = props; | |
// make a query to the server (or not??? we'll talk about this later) | |
const { data, loading, error } = useQuery(GET_START_CALL_SETTINGS, { | |
variables: { uuid }, | |
}); | |
if (loading) { | |
return <p>Loading...</p>; | |
} | |
if (error) { | |
return <p>Error!</p>; | |
} | |
// after the query is complete, get the session details... | |
const { apiKey, session, token } = data.sessionDetails; | |
// ... and pass them to opentok-react | |
return ( | |
<OTSession apiKey={apiKey} sessionId={session} token={token}> | |
<OTPublisher /> | |
<OTStreams> | |
<OTSubscriber /> | |
</OTStreams> | |
</OTSession> | |
); | |
}; | |
export default Room; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment