This project shows a picture about how to integrate with Agora fundamentally
- express
- Reading docs about agora: https://docs.agora.io/en/
- npm
npm install npm@latest -g
- Install the dependencies
npm install- Create a copy of the
.env.examplefile and save it as.env - Add your Agora App ID and App Certificate:
APP_ID=ca123xxxxxx
APP_CERTIFICATE=12za123xxxxxx
APP_CHAT_KEY=xxxxx#xxxxxx
ORIN_NAME=xxxxxxx
APP_NAME=xxxxxx
DOMAIN=https://a61.......
You can obtain these values by selecting your project in the Agora console projects section. Optionally, you can also define a port.
- Start the service ( recommend node 18 )
node --watch server.jsThe rtc token endpoint requires a channelName, role ('publisher' or 'audience'), tokentype ('uid' || 'userAccount') and the user's uid (type varies based on tokentype (example: 1000 for uid, ekaansh for userAccount).
(optional) Pass an integer to represent the token lifetime in seconds.
endpoint structure
/video-call/rtc/:channelName/:role/:tokentype/:uid/?expiry=
response:
{"rtcToken":" "}
The rtm token endpoint requires the user's uid.
(optional) Pass an integer to represent the privelege lifetime in seconds.
endpoint structure
/video-call/rtm/:uid/?expiry=
response:
{"rtmToken":" "}
The rte token endpoint generates both the rtc and rtm tokens with a single request.
(optional) Pass an integer to represent the token lifetime in seconds.
endpoint structure
/video-call/rte/:channelName/:role/:tokentype/:uid/?expiry=
response:
{
"rtcToken":" ",
"rtmToken":" "
}
Getting token to chat one to one.
endpoint structure
/chat/token
body:
{
"username":" ",
"password":" "
}
response:
{
"rtcToken":" "
}
Assign role super admin in order to manage a room chat.
endpoint structure
/chat/super-admin
body:
{
"username":" "
}
response:
{ }
- Agora's web demo: https://webdemo.agora.io/basicVideoCall/index.html