node-switcher
Switcher Node Addon
Last updated 4 months ago by vlaurent .
GPL-3.0 · Original npm · Tarball · package.json
$ cnpm install node-switcher 
SYNC missed versions from official npm registry.

Node-Switcher

Node-Switcher is the native NodeJS add-on for Switcher. It acts as a thin wrapper around Switcher's C++ API, allowing it to be included in Javascript applications. In the context of the Scenic stack, Node-Switcher is the link allowing Scenic Core to communicate with Switcher.

Node-Switcher is currently developed by the Société des Arts Technologiques [SAT], a non-profit artistic entity based in Montreal, CA. The current version of Node-Switcher has been tested with Ubuntu 18.04.

Installation

Dependencies

Name Version Command Description
Git latest sudo apt-get install git Distributed version control system used to get Node-Switcher source code
NodeJS >= 10.15.3 See NodeJS installation instructions JavaScript runtime which helps to build the Scenic engine
NPM >= 5.6.0 Included with the NodeJS installation JavaScript package manager used to build internal dependencies
libicu-dev latest sudo apt install libicu-dev Development library for handling of unicode characters
Shmdata >= 1.3.22 See Shmdata documentation Library to share flows of data frames between processes via shared memory
Switcher >= 2.1.0 See Switcher documentation C++ engine allowing the streaming of data over IP networks

Install with Scenic Core

Node-Switcher is specified as a dependency in Scenic Core's package.json. This means that Node-Switcher will be automatically downloaded, built and installed as part of Scenic Core's install process.

See Scenic Core's installation procedure for more information.

Install from Source

Your default g++ compiler must be 8 or greater.

Step Command
Clone the Node-Switcher repository git clone git@gitlab.com:sat-mtl/telepresence/node-switcher.git
Move into Scenic Core folder cd node-switcher
Install dependencies npm install
Build the application npm build

Additional Scripts

Additional NPM scripts are available to build the add-on:

node-gyp configure # configure node-gyp (optionnal)

npm run build
npm run build:debug # build for debug
npm run rebuild
npm run rebuild:debug # rebuild for debug

Install from Docker

The default Docker configuration uses the images built from Switcher. Docker-compose will fetch the develop branches from shmdata, switcher and node-switcher.

# Build the whole stack
docker-compose -f container/docker-compose.yml up

Build a Docker image

To build a Docker image of Node-Switcher, you'll need to build the Shmdata and Switcher images beforehand..

# Build node-switcher's image
docker build -t "node-switcher:develop" .

The node-switcher image uses [mutli-stage builds][docker-multi-stage] with 4 stages : dependencies, nodejs, build and clean. Theses stages use some build arguments :

arguments stages description default
SWITCHER_IMAGE dependencies The switcher base image registry.gitlab.com/sat-metalab/switcher
SWITCHER_TAG dependencies The tag of the switcher base image develop
NODEJS_VERSION nodejs NodeJS version to use 10
NODEJS_DOWNLOAD nodejs Link to the NodeJS binary https://deb.nodesource.com/setup_${NODEJS_VERSION}.x
BUILD_DIR build and clean Where node-switcher source is copied /opt/node-switcher

The node-switcher instance could be executed directly with its REPL :

docker run -ti node-switcher:develop node-switcher-repl

Usage

Javascript Scripting

Node-Switcher allows you to write JavaScript scripts to control Switcher. For example, you can use it to create quiddities, change a quiddity's properties, establish SIP communication with others, etc.

Example:

const Switcher = require('node-switcher').Switcher

const sw = new Switcher('debug', console.log)

// create a new quiddity `jacksrc`
sw.create('jacksrc')

You can see all examples in the folder example.

REPL Interface

You can also use a Read-Eval-Print Loop (REPL) in order to test Node-Switcher in the terminal. Type the following command in your terminal to do so:

# Inside node-switcher/
./bin/repl.js

Debugging

The following Visual Studio Code debug task can help you debug Node-Switcher. lldb and the vadimcn.vscode-lldb VSCode extension must be installed before running this task.

{
  "configurations": [{
    "name": "Node Switcher (lldb)",
    "type": "lldb",
    "request": "launch",
    "program": "${env:HOME}/.bin/node",
    "args": [
      "${workspaceFolder:node-switcher}/examples/debug.js"
    ],
    "preLaunchTask": "npm: build:dev"
  }]
}

Technologies

This add-on uses C++ 17 and NodeJS >= 10.

The SAT uses Ubuntu 18.04, so testing priority is given to this version.

Documentation

The NodeJs API is documented with source comments into cpp files. The documentation can be generated with JSDoc by running the command :

npm run doc

Contributing

Check out our Contributing Guide to get started!

Versioning

SemVer is used for versioning. For the versions available, see the tags on this repository.

Authors

See here.

License

This project is licensed under the GNU General Public License version 3 - see the LICENSE file for details.

Acknowledgments

This project was made possible by the Société des Arts Technologiques [SAT].

Current Tags

  • 3.1.1                                ...           latest (4 months ago)

11 Versions

  • 3.1.1                                ...           4 months ago
  • 3.1.0                                ...           6 months ago
  • 3.0.3                                ...           6 months ago
  • 3.0.2                                ...           7 months ago
  • 3.0.1                                ...           7 months ago
  • 3.0.0                                ...           a year ago
  • 0.4.3 [deprecated]           ...           6 years ago
  • 0.4.2 [deprecated]           ...           7 years ago
  • 0.1.2 [deprecated]           ...           7 years ago
  • 0.1.4 [deprecated]           ...           7 years ago
  • 0.1.0 [deprecated]           ...           7 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (2)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |