Commit 77a41641 authored by Bradley Hilton's avatar Bradley Hilton
Browse files

Start work on adding web sockets on the client, first step to getting a web interface

parent 6d80dbc2
......@@ -4,8 +4,10 @@ import * as bodyParser from 'body-parser';
import * as express from 'express';
import * as fs from 'fs';
import * as path from 'path';
import * as socketIO from 'socket.io';
const app = express();
let orch = new Orchestrator();
app.use(bodyParser.json());
......@@ -31,7 +33,7 @@ app.post('/event', (req, res) => {
res.json({ success: true });
});
app.listen(3003, function _appListen() {
const server = app.listen(3003, function _appListen() {
console.log('Example app listening on port 3003!');
console.log('http://localhost:3003/');
......@@ -39,3 +41,12 @@ app.listen(3003, function _appListen() {
.then(() => console.log('Completed the loading'))
.catch((err) => console.warn('Errored loadAndUpdate:', err));
});
const io = socketIO.listen(server);
io.on('connection', (socket) => {
socket.emit('news', { hello: 'world' });
socket.on('my other event', (data) => {
console.log(data);
});
});
......@@ -6,6 +6,7 @@
<body>
<h1 id="hello">Hello Earthlings</h1>
<script src="http://localhost:35729/livereload.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="index.js"></script>
</body>
</html>
(function _doIt() {
(function _doIt(io) {
const server = 'http://localhost:3003/';
document.getElementById('hello').style.color = 'blue';
fetch(server + 'loaded').then((res) => res.json()).then((items) => console.log(items));
})();
const socket = io.connect('http://localhost:3003');
socket.on('news', (data) => {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
})((window as any).io);
......@@ -84,6 +84,15 @@
"@types/mime": "1.3.1"
}
},
"@types/socket.io": {
"version": "1.4.29",
"resolved": "https://registry.npmjs.org/@types/socket.io/-/socket.io-1.4.29.tgz",
"integrity": "sha1-hqazqat4z5qQDO74W5totr6oZxI=",
"dev": true,
"requires": {
"@types/node": "8.0.7"
}
},
"accepts": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz",
......@@ -122,6 +131,12 @@
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz",
"integrity": "sha1-hgbCy/HEJs6MjsABdER/1Jtur8E="
},
"after": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
"integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=",
"dev": true
},
"ajv": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz",
......@@ -243,6 +258,12 @@
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=",
"dev": true
},
"arraybuffer.slice": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz",
"integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=",
"dev": true
},
"arrify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
......@@ -321,6 +342,12 @@
"regenerator-runtime": "0.10.5"
}
},
"backo2": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
"integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=",
"dev": true
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
......@@ -333,6 +360,18 @@
"integrity": "sha1-e0F0wvlESXU7EcJlHAg9qEGnsIQ=",
"dev": true
},
"base64-arraybuffer": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=",
"dev": true
},
"base64id": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz",
"integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=",
"dev": true
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
......@@ -349,6 +388,15 @@
"integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=",
"dev": true
},
"better-assert": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz",
"integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=",
"dev": true,
"requires": {
"callsite": "1.0.0"
}
},
"binary-search-tree": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/binary-search-tree/-/binary-search-tree-0.2.5.tgz",
......@@ -358,6 +406,12 @@
"underscore": "1.4.4"
}
},
"blob": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz",
"integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=",
"dev": true
},
"body-parser": {
"version": "1.17.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.17.2.tgz",
......@@ -433,6 +487,12 @@
"callsites": "0.2.0"
}
},
"callsite": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
"integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=",
"dev": true
},
"callsites": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz",
......@@ -534,6 +594,24 @@
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
"dev": true
},
"component-bind": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
"integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=",
"dev": true
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
"dev": true
},
"component-inherit": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz",
"integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
......@@ -889,6 +967,54 @@
}
}
},
"engine.io": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.1.0.tgz",
"integrity": "sha1-XKQ4486f28kVxKIcjdnhJmcG5X4=",
"dev": true,
"requires": {
"accepts": "1.3.3",
"base64id": "1.0.0",
"cookie": "0.3.1",
"debug": "2.6.7",
"engine.io-parser": "2.1.1",
"uws": "0.14.5",
"ws": "2.3.1"
}
},
"engine.io-client": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.1.tgz",
"integrity": "sha1-QVqYUrrbFPoAj6PvHjFgjbZ2EyU=",
"dev": true,
"requires": {
"component-emitter": "1.2.1",
"component-inherit": "0.0.3",
"debug": "2.6.7",
"engine.io-parser": "2.1.1",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"parsejson": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"ws": "2.3.1",
"xmlhttprequest-ssl": "1.5.3",
"yeast": "0.1.2"
}
},
"engine.io-parser": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.1.tgz",
"integrity": "sha1-4Ps/DgRi9/WLt3waUun1p+JuRmg=",
"dev": true,
"requires": {
"after": "0.8.2",
"arraybuffer.slice": "0.0.6",
"base64-arraybuffer": "0.1.5",
"blob": "0.0.4",
"has-binary2": "1.0.2"
}
},
"error-ex": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
......@@ -2432,6 +2558,29 @@
"ansi-regex": "2.1.1"
}
},
"has-binary2": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.2.tgz",
"integrity": "sha1-6D26SfC5vk0CbSc2U1DZ8D9Uvpg=",
"dev": true,
"requires": {
"isarray": "2.0.1"
},
"dependencies": {
"isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=",
"dev": true
}
}
},
"has-cors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
"integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=",
"dev": true
},
"has-gulplog": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz",
......@@ -2530,6 +2679,12 @@
"repeating": "2.0.1"
}
},
"indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
"dev": true
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
......@@ -3753,6 +3908,12 @@
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"dev": true
},
"object-component": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz",
"integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=",
"dev": true
},
"object-keys": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz",
......@@ -3921,6 +4082,33 @@
"integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=",
"dev": true
},
"parsejson": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/parsejson/-/parsejson-0.0.3.tgz",
"integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=",
"dev": true,
"requires": {
"better-assert": "1.0.2"
}
},
"parseqs": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz",
"integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=",
"dev": true,
"requires": {
"better-assert": "1.0.2"
}
},
"parseuri": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz",
"integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=",
"dev": true,
"requires": {
"better-assert": "1.0.2"
}
},
"parseurl": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz",
......@@ -4501,6 +4689,87 @@
"hoek": "2.16.3"
}
},
"socket.io": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.3.tgz",
"integrity": "sha1-Q1nwaiSTOua9CHeYr3jGgOrjReM=",
"dev": true,
"requires": {
"debug": "2.6.7",
"engine.io": "3.1.0",
"object-assign": "4.1.1",
"socket.io-adapter": "1.1.0",
"socket.io-client": "2.0.3",
"socket.io-parser": "3.1.2"
}
},
"socket.io-adapter": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.0.tgz",
"integrity": "sha1-x6pGUB3VVsLLiiivj/lcC14dqkw=",
"dev": true,
"requires": {
"debug": "2.3.3"
},
"dependencies": {
"debug": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz",
"integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=",
"dev": true,
"requires": {
"ms": "0.7.2"
}
},
"ms": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz",
"integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
"dev": true
}
}
},
"socket.io-client": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.3.tgz",
"integrity": "sha1-bK9K/5+FsZ/ZG2zhPWmttWT4hzs=",
"dev": true,
"requires": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
"debug": "2.6.7",
"engine.io-client": "3.1.1",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"socket.io-parser": "3.1.2",
"to-array": "0.1.4"
}
},
"socket.io-parser": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.1.2.tgz",
"integrity": "sha1-28IoIVH8T6675Aru3Ady66YZ9/I=",
"dev": true,
"requires": {
"component-emitter": "1.2.1",
"debug": "2.6.7",
"has-binary2": "1.0.2",
"isarray": "2.0.1"
},
"dependencies": {
"isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=",
"dev": true
}
}
},
"sort-keys": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
......@@ -4787,7 +5056,6 @@
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/temporary-rocketlets-ts-definition/-/temporary-rocketlets-ts-definition-0.6.1.tgz",
"integrity": "sha512-AqDgsBGGxADXbTM5ySHe+I3mJR6dW3Z+dR3VgojaKMIvBs/9G2lS4Ptf9Pko5nrzLGigyUvFQSf0Er1zqOO0HA==",
"dev": true,
"requires": {
"reflect-metadata": "0.1.10"
}
......@@ -4857,6 +5125,12 @@
"extend-shallow": "2.0.1"
}
},
"to-array": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz",
"integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=",
"dev": true
},
"tough-cookie": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz",
......@@ -4971,6 +5245,12 @@
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.1.tgz",
"integrity": "sha1-w8yxbdqgsjFN4DHn5v7onlujRrw="
},
"ultron": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz",
"integrity": "sha1-sHoualQagV/Go0zNRTO67DB8qGQ=",
"dev": true
},
"unc-path-regex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
......@@ -5071,6 +5351,13 @@
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
"integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g=="
},
"uws": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/uws/-/uws-0.14.5.tgz",
"integrity": "sha1-Z6rzPEaypYel9mZtAPdpEyjxSdw=",
"dev": true,
"optional": true
},
"v8flags": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz",
......@@ -5244,6 +5531,30 @@
"mkdirp": "0.5.1"
}
},
"ws": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-2.3.1.tgz",
"integrity": "sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=",
"dev": true,
"requires": {
"safe-buffer": "5.0.1",
"ultron": "1.1.0"
},
"dependencies": {
"safe-buffer": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz",
"integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=",
"dev": true
}
}
},
"xmlhttprequest-ssl": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz",
"integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0=",
"dev": true
},
"xtend": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
......@@ -5258,6 +5569,12 @@
"requires": {
"buffer-crc32": "0.2.13"
}
},
"yeast": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
"integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=",
"dev": true
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment