@careerkarma/ion-sdk-js
TypeScript icon, indicating that this package has built-in type declarations

1.5.8 • 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';
import { IonSFUJSONRPCSignal } from 'ion-sdk-js/lib/signal/json-rpc-impl';
const signal = new IonSFUJSONRPCSignal("wss://ion-sfu:7000");
const client = new Client(signal);
signal.onopen = () => client.join("test session")

// Setup handlers
client.ontrack = (track: MediaStreamTrack, stream: RemoteStream) => {
    // mute a remote stream
    stream.mute()
    // unmute a remote stream
    stream.unmute()

    if (track.kind === "video") {
         // prefer a layer
         stream.preferLayer("low" | "medium" | "high")
    }
});

// Get a local stream
const local = await LocalStream.getUserMedia({
    audio: true,
    video: true,
    simulcast: true, // enable simulcast
});

// Publish stream
client.publish(local);

// mute local straem
local.mute()

// unmute local stream
local.unmute()

// create a datachannel
const dc = client.createDataChannel("data")
dc.onopen = () => dc.send("hello world")

// Close client connection
client.close();

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.5.8
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.5.8
    1
  • 1.5.7
    0
  • 1.5.6
    0
  • 1.5.5
    0

Package Sidebar

Install

npm i @careerkarma/ion-sdk-js

Weekly Downloads

1

Version

1.5.8

License

MIT

Unpacked Size

446 kB

Total Files

18

Last publish

Collaborators

  • n.rybitskyi
  • careerkarma_admin