@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));