Skip to content

Managed WebSocket SDK API

miskun edited this page Mar 26, 2014 · 3 revisions

MWS - Constructor

MWS - Client-side APIs

MWS - The WebSocket

MWS - Server-side APIs

Note! In order to use following API's you need to configure secret token for MWS instance and supply it for the Qtc.Mws() constructor.

MWS - Generic REST API for making custom requests

Qtc.Mws()

var mws = new Qtc.Mws( options );

The constructor for MWS instance. The options is an object with following parameters:

  • address - An address of this MWS instance
  • backendId - A backend id of this MWS instance
  • secret - (optional) A security token for this MWS instance
// The typical constructor may look something like this...
var mws = new Qtc.Mws({
   address: "",     // enter your MWS instance address
   backendId: "",   // enter your MWS instance backend id
   secret: ""       // optionally, enter your MWS instance secret token
});

Qtc.Mws.getSocketAddress()

mws.getSocketAddress( callback )

Qtc.Mws.send()

mws.send( msg, receivers, callback)

Qtc.Mws.socket()

var socket = new mws.socket( options )

The constructor for WebSocket connection. This is used to establish the actual WebSocket connection. This SDK is using node module ws for its WebSocket implementation. Please see the supported options and usage instructions at https://github.com/einaros/ws

// open WebSocket
var socket = new mws.socket( "WEBSOCKET_ADDRESS_HERE" );

// set some event handlers
socket.on('open', function() {
    console.log('connected');
});
socket.on('close', function() {
    console.log('disconnected');
});
socket.on('message', function(data) {
    console.log('message', data);
});

Qtc.Mws.getSockets()

mws.getSockets( callback )

Qtc.Mws.getSocketInfo()

mws.getSocketInfo( id, callback )

Qtc.Mws.createSocket()

mws.createSocket( tags, callback )

Qtc.Mws.getConfiguration()

mws.getConfiguration( callback )

Qtc.Mws.setConfiguration()

mws.setConfiguration( config, callback)

Qtc.Mws.rest()

mws.rest( verb, path, options, callback )