Server SDK
The Server SDK helps you to perform server-side operation such as generating Access Token, calling APIs such as Create Room
, Live Meetings
, etc, starting and stopping recording and livestream, and send messages from server-side.
Installation
npm install @huddle01/server-sdk@latest
Generating Access Token
Access Token is required to join a room. You can generate access token using the following code.
⚠️
Use Server SDK on server side only, don't use it on client side.
const accessToken = new AccessToken({
apiKey: "YOUR_API_KEY",
roomId: "YOUR_ROOM_ID",
//available roles: Role.HOST, Role.CO_HOST, Role.SPEAKER, Role.LISTENER, Role.GUEST - depending on the privileges you want to give to the user
role: Role.HOST,
//custom permissions give you more flexibility in terms of the user privileges than a pre-defined role
permissions: {
admin: true,
canConsume: true,
canProduce: true,
canProduceSources: {
cam: true,
mic: true,
screen: true,
},
canRecvData: true,
canSendData: true,
canUpdateMetadata: true,
},
options: {
metadata: {
// you can add any custom attributes here which you want to associate with the user
walletAddress: "mizanxali.eth",
},
},
});
const token = accessToken.toJwt();