/minnie-janus

A small, modern, general interface for the Janus WebRTC gateway, written in ES8 Javascript for browsers and Node.js

Primary LanguageJavaScriptMIT LicenseMIT

minnie-janus

Test badge

A small, modern, general interface module written in ES8 Javascript for the Janus WebRTC gateway API, for browsers as well as Node.js.

Inspiration came from the project minijanus (hence this name, 'minnie-janus'), but this is a rewrite from scratch because I needed ES modules, events, async/await syntax, better logging, and a fix of one small API issue in minijanus.

Provided are two behavior implementations, Session (see src/session.js) and BasePlugin (see src/base-plugin.js), which transparently map to their server-side equivalents.

BasePlugin is supposed to be extended with per-plugin logic before being attached to a Session instance, because Janus plugins are more like applications with very specific behavior. See examples below on how to extend the BasePlugin implementation.

Neither Session nor BasePlugin instances actually communicate with janus-gateway. The parent application instantiating a Session is responsible for wiring up the transport of choice (REST HTTP(S), (Secure) WebSockets, etc.) to the Session.receive() method and the Session#output event.

Usage of mini-janus is best illustrated by the full demo/example implementing the 'echotest' plugin (included in Janus' source code). It can be found in the demo subdirectory (see also demo/README.md there).

The implementation has been tested with the following janus-gateway versions:

  • 0.7.4
  • 0.8.1

How to use BasePlugin

The 'echotest' demo contained in this repository extends BasePlugin with plugin-specific behavior and exports a "Stamp", but also gives examples how to extend BasePlugin and return ...

  • a factory function,
  • a constructor function,
  • a class.

By the way, "Stamps" are an awesome way to compose objects in OOP. See: https://github.com/stampit-org/stampit