-
-
Save DanyF-github/54591acf87d4a3a7698c08cc9fcf17ee 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
// server/src/graphql/videoApi.js | |
... | |
const startSession = async (_, __, ___, ____) => { | |
try { | |
// initialize opentok | |
initializeOpentok(); | |
// create the session | |
const session = await createSession(); | |
// generate an id | |
const uuid = uuidv4(); | |
// save the session | |
videocalls.push({ | |
uuid, | |
sessionId: session.sessionId, | |
}); | |
// generate a token with moderator privileges | |
const token = session.generateToken({ | |
role: 'moderator', | |
data: `role=moderator`, | |
}); | |
// return date honoring the format for SessionResponse type | |
return { | |
uuid, | |
token, | |
session: session.sessionId, | |
apiKey, | |
}; | |
} catch (e) { | |
console.error('An error occurredocurred when creating opentok session', e); | |
} | |
}; | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment