@pexip/vpaas-api
TypeScript icon, indicating that this package has built-in type declarations

19.0.1 • Public • Published

@pexip/vpaas-api

Type-safe wrappers for VPaaS.

Install

npm install @pexip/vpaas-api

Meeting CRUD API

We provide a wrapper for all the CRUD API actions

const api = createApi(apiAddress, getToken);

// Creates new meeting
const abortController = new AbortController();
const meetingId = await api.create({abortSignal: abortController.signal});
...
// Generates `participant_id` and `participant_secret`
const abortController = new AbortController();
const {data: {participant_id, participant_secret}} = await api.participants({
    meetingId,
    abortSignal: abortController.signal,
});
...
// Joins a meeting
const abortController = new AbortController();
const {data: {location, token}} = await api.join({
    meetingId,
    participantId,
    participantSecret,
    abortSignal: abortController.signal,
});
// Terminates a meeting
const abortController = new AbortController();
api.terminate({abortSignal: abortController.signal, meetingId})

Meeting event types

After we successfuly join a meeting all the real-time communication is provided via WebSocket channel.

We provide ts types for all the available events.

const ws = new WebSocket(location);

ws.onmessage = (msg: MessageEvent<string>) => {
  const event = JSON.parse(msg.data) as VpaasWebsocketMessageTypesUnion;
  switch (event.type) {
    case 'roster_update':
      //...
      break;
    //...
  }
};

const send = (msg: VpaasWebsocketMessageTypesUnion) =>
  ws.send(JSON.stringify(msg));

Readme

Keywords

none

Package Sidebar

Install

npm i @pexip/vpaas-api

Weekly Downloads

38

Version

19.0.1

License

Apache-2.0

Unpacked Size

72.2 kB

Total Files

19

Last publish

Collaborators

  • npm-pexip