Running a receiver application on a PC

To run a receiver app on a PC, follow this sequence:

  1. Create the receiver folder.
  2. Create the ./receiver/package.json file with the following content:
{"name": "receiver","version": "1.0.0","description": "","main": "index.js","scripts": {  "start": "node index.js",  "test": "echo \"Error: no test specified\" && exit 1"},"author": "","license": "ISC","dependencies": {  "ws": "^2.3.1"}}
  1. Create the ./receiver/index.js file with the following content:
const WebSocket = require('ws');const wss = new WebSocket.Server({port: 8080}, function () { console.log('Websocket server started');});wss.on('connection', function connection(ws) { ws.on('message', function incoming(message) { console.log('received: ', message); ...

Get Industrial Internet Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.