2017-12-02 21:25:04 +01:00
|
|
|
const app = require('express')();
|
|
|
|
const http = require('http').Server(app);
|
|
|
|
const io = require('socket.io')(http);
|
|
|
|
|
|
|
|
const port = 6676;
|
|
|
|
|
|
|
|
const include_files = [
|
|
|
|
'/three.min.js',
|
|
|
|
'/anim.js',
|
|
|
|
'/control.js',
|
|
|
|
'/nouislider.min.js',
|
|
|
|
'/nouislider.min.css',
|
|
|
|
'/lodash.min.js',
|
|
|
|
];
|
|
|
|
|
|
|
|
app.get('/', function(req, res) {
|
2017-10-06 23:20:52 +02:00
|
|
|
res.sendFile(__dirname + '/index.html');
|
|
|
|
});
|
|
|
|
|
2017-12-02 21:25:04 +01:00
|
|
|
app.get('/ctl', function(req, res) {
|
2017-10-06 23:20:52 +02:00
|
|
|
res.sendFile(__dirname + '/control.html');
|
|
|
|
});
|
|
|
|
|
2017-12-02 21:25:04 +01:00
|
|
|
let settings = {};
|
|
|
|
app.get('/settings', function(req, res) {
|
|
|
|
res.send(settings);
|
2017-10-06 23:20:52 +02:00
|
|
|
});
|
|
|
|
|
2017-12-02 21:25:04 +01:00
|
|
|
include_files.map(function(file) {
|
|
|
|
app.get(file, function(req, res){
|
|
|
|
res.sendFile(__dirname + file);
|
|
|
|
});
|
2017-10-06 23:20:52 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/socket.io.js', function(req, res){
|
|
|
|
res.sendFile(__dirname + '/node_modules/socket.io-client/dist/socket.io.js');
|
|
|
|
});
|
|
|
|
|
|
|
|
io.on('connection', function(socket){
|
|
|
|
console.log('konekt');
|
|
|
|
|
|
|
|
socket.on('disconnect', function(){
|
|
|
|
console.log('diskonekt');
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.on('adjust', function(name, val) {
|
2017-12-02 21:25:04 +01:00
|
|
|
settings[name] = val;
|
|
|
|
io.emit('adjust', name, val, socket.id);
|
2017-10-06 23:20:52 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-02 21:25:04 +01:00
|
|
|
http.listen(port, function(){
|
|
|
|
console.log('listening on *:' + port);
|
2017-10-06 23:20:52 +02:00
|
|
|
});
|