Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

ion-sdk-js

0.4.1 • Public • Published

ion-sdk-js

Frontend sdk for the Ion backend.

Installation

npm install ion-sdk-js

Usage

import { Client, LocalStream, RemoteStream } from 'ion-sdk-js';
const client = new Client({ url: 'wss://endpoint/ws' });
 
// Setup handlers
client.on('peer-join', (uid: string, info: any) => {});
client.on('peer-leave', (uid: string) => {});
client.on('transport-open', () => {}));
client.on('transport-closed', () => {});
client.on('stream-add', (uid: string, info: any) => {});
client.on('stream-remove', (stream: RemoteStream) => {});
client.on('broadcast', (uid: string, info: any) => {});
 
// Join a room
client.join(rid, {
    name: "name"
});
 
// Leave current room
client.leave();
 
// Get a local stream
const local = await LocalStream.getUserMedia({
    audio: true,
    video: true
});
 
// Publish local stream
client.publish(local);
 
// Unpublish local stream
local.unpublish();
 
// Subscribe to a remote stream
const remote = client.subscribe(mid);
 
// Unsubscribe from a stream
remote.unsubscribe();
 
// Broadcast a payload to the room
client.broadcast(payload);
 
// Close client connection
client.close();
 
// To add your custom stream
import { LocalStream } from 'ion-sdk-js';
(...)
var streamOptions = {
        codec'VP8',
        resolution'hd'
    }
var myLocalStream = new LocalStream (yourStreamHere, streamOptions)
 

Install

npm i ion-sdk-js

DownloadsWeekly Downloads

355

Version

0.4.1

License

MIT

Unpacked Size

32 kB

Total Files

15

Last publish

Collaborators

  • avatar