websocket-multiplex icon indicating copy to clipboard operation
websocket-multiplex copied to clipboard

Example for raw websockets

Open hamiltont opened this issue 11 years ago • 0 comments

Here's an example for raw websockets (instead of sockjs). It appears that onmessage, onclose, etc, used in the sockjs examples don't apply to raw websockets.

var ws = new WebSocket('ws://' + foo);
var pubsub = new WebSocketMultiplex(ws); 

var logs = pubsub.channel('/logs');
logs.addEventListener('message', function(dataObject) {
  console.log('logs got data ' + dataObject.data);
});

hamiltont avatar Sep 29 '14 14:09 hamiltont