/** * 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'); } };