SODashServer/routes/projector_v1.js
Martin Donnelly d93ebb4466 init
2016-04-13 10:01:28 +01:00

54 lines
985 B
JavaScript

/**
* Created by Martin on 10/02/2016.
*/
"use strict";
/**
* Created by Martin on 09/02/2016.
*/
var mqttConnect;
function doProjectorOn() {
mqttConnect.doConnection().projectorOn();
}
function doProjectorOff() {
mqttConnect.doConnection().projectorOff();
}
function setUseRef(ref) {
mqttConnect = ref;
}
module.exports = {
mqttConnect:null,
socket:null,
use: function (ref) {
setUseRef(ref);
},
turnoff: function (req, res) {
doProjectorOff();
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({}));
},
turnon: function (req, res) {
doProjectorOn();
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({}));
},
setsocket: function (socket) {
this.socket = socket;
return this;
},
subscribe: function (socket) {
this.socket.subscribe('ProjectorISP15','ProjectorDataReceived');
}
};