Socket
Book a DemoInstallSign in
Socket

@nabla/janus-client

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nabla/janus-client

Javascript client for Janus-Gateway server

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
3
Weekly downloads
 
Created
Source

janus-client

Javascript web client for a WebRTC Janus server.
The js file comes from the official Janus repository while the typing one, index.d.ts is tailored for the videoroom plugin.

Install

yarn add @nabla/janus-client

Usage

import Janus, { JSEP, PluginHanlde } from "@nabla/janus-client";

let session: Janus;
let localHandle: PluginHandle;
const opaqueId = "<OPAQUE_ID>";

Janus.init({
  debug: true,
  callback: () => {
    session = new Janus({
      server: serverUrl, // TODO get media server url dynamically from back-end
      withCredentials: true,
      success: () => {
        session.attach({
          plugin: "janus.plugin.videoroom",
          opaqueId,
          success: (pluginHandle) => {
            localHandle = pluginHandle;

            pluginHandle.send({
              message: {
                request: "join",
                room: 1234, // Your room id
                ptype: "publisher",
                display: "<USER_NAME>",
              },
            });
          },
          error: (err) => {
            // ...
          },
          iceState: (state) => {
            // ...
          },
          mediaState: (medium, on) => {
            // ...
          },
          webrtcState: (on) => {
            // ...
          },
          slowLink: () => {
            // ...
          },
          onmessage: (msg, jsep) => {
            const event = msg.videoroom;
            if (event === "joined") {
              // We can publish our own feed;
              // ...

              if (msg.publishers) {
                for (const p of msg.publishers) {
                  // Add remote feed
                  // ...
                }
              }
            } else if (event === "event") {
              if (msg.publishers) {
                // There are new participants joining the room
                for (const p of msg.publishers) {
                  // Add remote feed
                  // ...
                }
              } else if (msg.leaving) {
                // A participant is leaving the room...
                // ...
              } else if (msg.unpublished) {
                // A participant unpublished
                // ...
              }
            } else if (event === "destroyed") {
              // The room is closed...
            }

            if (jsep) {
              localHandle.handleRemoteJsep({ jsep });
            }
          },
          onlocalstream: (stream) => {
            // local video can be attached
          },
          // ...
        });
      },
      error: (err) => {
        // An error occured
      },
    });
  },
});

Keywords

janus

FAQs

Package last updated on 29 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.