-
Notifications
You must be signed in to change notification settings - Fork 2
Managed WebSocket SDK API
miskun edited this page Mar 26, 2014
·
3 revisions
MWS - Constructor
- Qtc.Mws() - Constructor
MWS - Client-side APIs
- Qtc.Mws.getSocketAddress() - Get socket address
- Qtc.Mws.send() - Send message to WebSocket(s) over HTTP REST API
MWS - The WebSocket
- Qtc.Mws.socket() - The WebSocket connection constructor.
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.
- Qtc.Mws.getSockets() - Get list of all socket connection
- Qtc.Mws.getSocketInfo() - Get info about single socket connection by its id
- Qtc.Mws.createSocket() - Create (or make a reservation for) a socket
- Qtc.Mws.getConfiguration() - Get MWS instance configuration
- Qtc.Mws.setConfiguration() - Update MWS instance configuration
MWS - Generic REST API for making custom requests
- Qtc.Mws.rest() - Make custom API request to MWS instance
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
});
mws.getSocketAddress( callback )
mws.send( msg, receivers, callback)
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);
});
mws.getSockets( callback )
mws.getSocketInfo( id, callback )
mws.createSocket( tags, callback )
mws.getConfiguration( callback )
mws.setConfiguration( config, callback)
mws.rest( verb, path, options, callback )