1.0.1 • Published 6 years ago

mm-websockets v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Matter In Motion. Websockets transport

NPM Version NPM Downloads

Websocket transport extension for matter in motion framework

Usage

Transport installation instructions

Protocol

Websockets from the browser:

const msg = [ <request>, <data object>, <head object>, <requestId> ];
const con = new WebSocket('ws://localhost:3000/api');
con.onmessage = function(e) {
  const res = JSON.parse(e.data);
  console.log(res);
}

con.onopen = function() {
  con.send(JSON.stringify(msg));
};

Settings

  • pingInterval — number. Ping interval in milliseconds
  • type string, 'application/json'. Default type of data, 'application/json' is onlt available option for now.
  • port number, if defined creates its own http server and listens port, otherwise tries to use http transport server
  • serializer — string, serializer name to be used as default for websockets messages instead of default

License: MIT.