Comment out restify endpoints in server module

This commit is contained in:
mmcw-dev 2018-01-11 06:25:17 -05:00
parent 465993ce33
commit 407134af7e
1 changed files with 47 additions and 43 deletions

View File

@ -9,63 +9,67 @@ let proj
let light let light
class Server { class Server {
constructor (mcopy) { constructor (camera, projector, light) {
restify = require('restify') restify = require('restify')
os = require('os') os = require('os')
app = express() app = restify.createServer({
name: 'mcopy-server',
version: '2.0.0'
})
this.ip = this.getIp()
this.getIp() /*app.get('/', function (req, res) {
app.get('/', function (req, res) {
mcopy.mobile.log('Device connected'); mcopy.mobile.log('Device connected');
res.send(fs.readFileSync('tmpl/mcopy_index.html', 'utf8')); res.send(fs.readFileSync('tmpl/mcopy_index.html', 'utf8'));
})
app.get('/js/mcopy_mobile.js', function (req, res) {
res.send(fs.readFileSync('js/mcopy_mobile.js', 'utf8'));
}); });
app.get('/js/mcopy_mobile.js', function (req, res) { app.get('/js/jquery.js', function (req, res) {
res.send(fs.readFileSync('js/mcopy_mobile.js', 'utf8')); res.send(fs.readFileSync('js/jquery.js', 'utf8'));
}); });
app.get('/js/jquery.js', function (req, res) { app.get('/cmd/:cmd', function (req, res) {
res.send(fs.readFileSync('js/jquery.js', 'utf8')); var cmd,
}); success = function (res) {
app.get('/cmd/:cmd', function (req, res) { var obj = {
var cmd, success: true,
success = function (res) { cmd : cmd,
var obj = { cam : mcopy.state.camera,
success: true, proj : mcopy.state.projector
cmd : cmd, }
cam : mcopy.state.camera, res.json(obj);
proj : mcopy.state.projector };
if (typeof req.params.cmd !== 'undefined') {
mcopy.log('Receiving command from mobile: ' + req.params.cmd);
cmd = req.params.cmd;
if (cmd === 'CF'){
mcopy.cmd.cam_forward(success);
} else if (cmd === 'CB') {
mcopy.cmd.cam_backward(success);
} else if (cmd === 'PF') {
mcopy.cmd.proj_forward(success);
} else if (cmd === 'PB') {
mcopy.cmd.proj_backward(success);
} else {
mcopy.mobile.fail(res, 'Command ' + cmd + ' not found');
} }
res.json(obj);
};
if (typeof req.params.cmd !== 'undefined') {
mcopy.log('Receiving command from mobile: ' + req.params.cmd);
cmd = req.params.cmd;
if (cmd === 'CF'){
mcopy.cmd.cam_forward(success);
} else if (cmd === 'CB') {
mcopy.cmd.cam_backward(success);
} else if (cmd === 'PF') {
mcopy.cmd.proj_forward(success);
} else if (cmd === 'PB') {
mcopy.cmd.proj_backward(success);
} else { } else {
mcopy.mobile.fail(res, 'Command ' + cmd + ' not found'); mcopy.mobile.fail(res, 'No command provided');
} }
} else {
mcopy.mobile.fail(res, 'No command provided');
}
});
app.get('/state', function (req, res) {
res.json({
cam: mcopy.state.camera,
proj: mcopy.state.projector
}); });
}); app.get('/state', function (req, res) {
var http = require('http'); res.json({
http.createServer(app).listen(mcopy.cfg.ext_port); cam: mcopy.state.camera,
proj: mcopy.state.projector
});
});*/
} }
end () { end () {
app.close() app.close()
app = null
} }
} }