Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 556 Bytes

README.md

File metadata and controls

30 lines (23 loc) · 556 Bytes

Node WebSocket Demo

Enabels communication between two web pages.

Running the server

Just install the dependencies and run app.js:

npm install
node app.js

Connecting as Broadcaster

var ws = new WebSocket('ws://localhost:8080');

ws.onopen = function(evt) {
  this.send( JSON.stringify({"type":"init","data":"primary"}) );
};

Connecting as listener

var ws = new WebSocket('ws://localhost:8080');

ws.onopen = function(evt) {
  this.send( JSON.stringify({"type":"init","data":"secondary"}) );
};