wpCloud WebSocket API
by andypotanin
JavaScript
var connection = new WebSocket('ws://api.usabilitydynamics.com');
console.log('connection', connection);
// Send the message 'Ping' to the server
connection.onopen = function () {
connection.send('ping');
};
// Log errors
connection.onerror = function (error) {
console.log('WebSocket Error ' + error);
};
// Log messages from the server
connection.onmessage = function (e) {
console.info('Server: ' + e.data);
if (e.data === 'dong') {
console.log('got a dong back');
}
};