Skip to content

adammiller/node-websocket-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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"}) );
};

About

Simple WebSocket server for broadcasting messages between webpages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published