Skip to content

Instantly share code, notes, and snippets.

@digitallysavvy
Created July 16, 2020 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitallysavvy/89af0b5cb6f29a92d627e75b6bed1f5d to your computer and use it in GitHub Desktop.
Save digitallysavvy/89af0b5cb6f29a92d627e75b6bed1f5d to your computer and use it in GitHub Desktop.
a snippet that gets the query params for an Agora token server.
// get uid
let uid = req.query.uid;
if(!uid || uid == '') {
uid = 0;
}
// get role
let role = RtcRole.SUBSCRIBER;
if (req.query.role == 'publisher') {
role = RtcRole.PUBLISHER;
}
// get the expire time
let expireTime = req.query.expireTime;
if (!expireTime || expireTime == '') {
expireTime = 3600;
} else {
expireTime = parseInt(expireTime, 10);
}
// calculate privilege expire time
const currentTime = Math.floor(Date.now() / 1000);
const privilegeExpireTime = currentTime + expireTime;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment