Created
July 16, 2020 18:51
-
-
Save digitallysavvy/89af0b5cb6f29a92d627e75b6bed1f5d to your computer and use it in GitHub Desktop.
a snippet that gets the query params for an Agora token server.
This file contains hidden or 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
// 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