0.3.0 • Published 7 months ago

@100mslive/server-sdk v0.3.0

Weekly downloads
-
License
GPL-3.0-only
Repository
-
Last release
7 months ago

100ms NodeJs Server Side SDK

Note

This is beta, APIs might change

Documentation

The examples/nodejs folder on root has some examples.

Docs

Env Variables to configure(optional)

  • HMS_ACCESS_KEY => access key as present in dashboard's developer section
  • HMS_SECRET => app secret as present in dashboard's developer section

Create SDK Instance

const sdk = new HMSSDK(accessKey, secret);

Generating management token

console.log(await sdk.getManagementToken());
// with token options -
console.log(await sdk.getManagementToken({ issuedAt, notValidBefore, validForSeconds }));

Generating Auth token

console.log(await sdk.getAuthToken({ roomId, role, userId }));
// with token options -
console.log(
  await sdk.getAuthToken({ roomId, role, userId, issuedAt, notValidBefore, validForSeconds })
);

Creating and Updating Room

const roomService = sdk.getRoomService();
const room = await roomService.createRoom();
// with room options -
const roomWithOptions = await roomService.createRoom({ name, description, recording_info, region });

const updatedRoom = await roomService.updateRoom(room.id, { name });
console.log(room, roomWithOptions, updatedRoom);

List Peers in an Active Room and send a Message

const activeRoomService = sdk.getActiveRoomService();
const peers = await getActivePeers(roomId);
console.log(peers);

await sendMessage(roomId, { message: "test" });

Get all Sessions

const sessionService = sdk.getSessionService();
const allSessionsIterable = await getAllSessionsIterable();

const allSessions = [];
while (true) {
  const someSessions = await allSessionsIterable.next();
  if (someSessions.length == 0) break;
  sessions.push(...someSessions);
}
console.log(allSessions);

Errors

Errors will follow the below interface, code is HTTP Status Code.

interface HMSException {
  code?: number;
  name: string;
  message: string;
}

e.g.

const hlsErr = {
  code: 404,
  name: "Not Found",
  message: "hls not running",
};
0.3.1-alpha.0

7 months ago

0.3.2-alpha

2 years ago

0.3.0-alpha

2 years ago

0.3.1-alpha

2 years ago

0.3.0

2 years ago

0.1.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.4

2 years ago

0.1.0-alpha

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago