-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.js
64 lines (55 loc) · 1.48 KB
/
dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const budo = require('budo');
const path = require('path');
const opn = require('opn');
const fs = require('fs');
const simpleHtml = require('simple-html-index');
// const Kinect2 = require('kinect2');
const babelify = require('babelify')
const ws = require('ws');
var entryPath = path.resolve('src', 'index.js');
budo(entryPath, {
serve: 'js/index.js',
live: true,
dir: __dirname + '/app',
stream: process.stdout,
defaultIndex: function (opt) {
var html = 'index.html';
if (!fs.existsSync(html)) return simpleHtml(opt);
return fs.createReadStream(html);
},
browserify: {
transform: [
babelify,
['installify', {save: true}],
['glslify', {global: true}]
]
}
}).on('connect', function (ev) {
const uri = ev.uri + 'index.html';
opn(uri);
});
const wss = new ws.Server({ port: 8080 });
// const kinect = new Kinect2();
wss.broadcast = function broadcast(data) {
wss.clients.forEach(function each(client) {
if (client.readyState === ws.OPEN) {
client.send(data, function (e) {});
}
});
};
wss.on('connection', function connection(ws) {
console.log('someone connected')
});
wss.on('listening', function l() {
console.log('ws listening')
// if (kinect.open()) {
// console.log("---Kinect Opened---");
// kinect.on('bodyFrame', function (bodyFrame) {
// wss.broadcast(JSON.stringify(bodyFrame.bodies));
// });
// kinect.openBodyReader();
// }
});
wss.on('error', function connection(e) {
console.log(e);
});