Skip to content

matter-in-motion/mm-websockets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.