3.2.0 • Published 4 years ago

node-switcher v3.2.0

Weekly downloads
3
License
GPL-3.0
Repository
-
Last release
4 years ago

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

IMPORTANT: Take note that Node-Switcher 3.2.x is only compatible with Switcher 2.1.24 and up. Use Node-Switcher 3.1.2 if you plan to use a version of Switcher lower than 2.1.24.

NameVersionCommandDescription
G++/GCC>= 8sudo apt-get install gcc-8 g++-8GNU project C and C++ compiler
libicu-devlatestsudo apt install libicu-devDevelopment library for handling of unicode characters
Gitlatestsudo apt-get install gitDistributed version control system used to get Node-Switcher source code
NodeJS>= 10.15.3See NodeJS installation instructionsJavaScript runtime which helps to build the Scenic engine
NPM>= 5.6.0Included with the NodeJS installationJavaScript package manager used to build internal dependencies
Shmdata>= 1.3.32See Shmdata documentationLibrary to share flows of data frames between processes via shared memory
Switcher>= 2.1.24See Switcher documentationC++ 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

StepCommand
Clone the Node-Switcher repositorygit clone git@gitlab.com:sat-mtl/telepresence/node-switcher.git
Move into Node Switcher foldercd node-switcher
Build the appnpm install

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 with 4 stages : dependencies, nodejs, build and clean. Theses stages use some build arguments :

argumentsstagesdescriptiondefault
SWITCHER_IMAGEdependenciesThe switcher base imageregistry.gitlab.com/sat-metalab/switcher
SWITCHER_TAGdependenciesThe tag of the switcher base imagedevelop
NODEJS_VERSIONnodejsNodeJS version to use10
NODEJS_DOWNLOADnodejsLink to the NodeJS binaryhttps://deb.nodesource.com/setup_${NODEJS_VERSION}.x
BUILD_DIRbuild and cleanWhere 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].

3.2.0

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

5 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.1.2

11 years ago

0.1.4

11 years ago

0.1.0

11 years ago