Show pagesource Old revisions Backlinks Table of Contents Websockets Script Part Client Part Websockets Script Part See documentation for more information. var ws = require('ws'); var event = require('event'); ws.broadcast(1, { blubb: 'blubb' }); event.on('ws.connect', function(id) { ws.write(id, 1, { blubb: 'blubb' }); }); event.on('ws.disconnect', function(id) { }); event.on('ws.data', function(id, type, data) { var data = JSON.parse(data.toString()); }); Client Part var proto = (window.location.protocol == 'https:') ? 'wss' : 'ws'; var conn = new WebSocket(proto + "://" + document.location.host + "/api/v1/b/" + botId + "/i/" + instanceId + "/ws"); conn.onclose = function (evt) { console.log('close', evt); alert('Closed.'); }; conn.send(JSON.stringify({ type: 'ping' })); conn.onmessage = function (evt) { var data = JSON.parse(evt.data); };