Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@dytesdk/opentok-shim

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dytesdk/opentok-shim

Dyte's OpenTok client-side shim

latest
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Logo

Opentok shim by dyte


Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

About The Project

This package @dytesdk/opentok-shim is a wrapper over the Dyte SDK with a Opentok compatible external API. It is a drop-in replacement for Opentok JS, and supports most of the methods and events that are present in the library.

Built With

Getting Started

You can install the @dytesdk/opentok-shim from the NPM Registry using the npm install command.

npm install @dytesdk/opentok-shim

Usage

The @dytesdk/opentok-shim shares the same API as the opentok Video SDK. You can use most of the methods that are supported by it. Here's a compatibility specification that describes the methods from opentok-video that are supported by this @dytesdk/opentok-shim package.

Here are a few examples: Replace:

import * as OT from "@opentok/client";

with

import * as OT from "@dytesdk/opentok-shim";

Connection

const token = "<DYTE-AUTH-TOKEN>";
const sessionId = "";
const session = OT.initSession(token, sessionId);
session.on("streamCreated", function streamCreated(event) {
  console.log("[streamCreated] index.ts: ", event.stream);
  session.subscribe(
    event.stream,
    "subscriber",
    {
      insertMode: "append",
      width: "100%",
      height: "100%",
    },
    handleError
  );
  // }
});

let connections: OT.Connection[] = [];
session.on("connectionCreated", (connectionCreatedEvent) => {
  console.log("session connectionCreatedEvent: ", connectionCreatedEvent);
  connections.push(connectionCreatedEvent.connection);

  if (
    connections.find(
      (connection) =>
        connection.connectionId ===
        connectionCreatedEvent.connection.connectionId
    )
  ) {
    console.log("connection already exists");
    return;
  }
  connections.push(connectionCreatedEvent.connection);
});

session.on("connectionDestroyed", (connectionDestroyedEvent) => {
  console.log("session connectionDestroyedEvent: ", connectionDestroyedEvent);
  connections = connections.filter(
    (connection) =>
      connection.connectionId !==
      connectionDestroyedEvent.connection.connectionId
  );
});

About

opentok-shim is created & maintained by Dyte, Inc. You can find us on Twitter - @dyte_io or write to us at dev [at] dyte.io.

The names and logos for Dyte are trademarks of Dyte, Inc.

We love open source software! See our other projects and our products.

FAQs

Package last updated on 30 Apr 2023

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