Page tree

This example requires a valid token. To find out how to get a valid token, please read the Obtain Authorization page.  

To run this example, you need to install socket.io and socket.io-client modules on your local machine.

For Socket.io documentation, click here.

/**
* VoipNow API Notification - NodeJS Quick Example
*/

var util = require('util');
var io = require('socket.io-client');

var accessToken = "CHANGEME";
var appId = "CHANGEME";
var instanceId = "CHANGEME";
var deviceId = "CHANGEME";
var host = "CHANGEME";

var serviceEndpoint = "/hubgetsb/ws/" + deviceId + "/" + instanceId;
var socket = io.connect(host, {
	query: "access_token=" + accessToken,
	transports: ['websocket'],
	path: serviceEndpoint
});

socket.on('connect', function(data){
	console.log('connected !\nwaiting for messages...');
});
socket.on('message', function(data){
	console.log(data);
});
socket.on('error', function(err) {
  console.log('error: ' + err);
});
socket.on('disconnect', function(){
	console.log('disconnected');
});
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels

Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.