mirror of
https://gitlab.silvrtree.co.uk/martind2000/SODashServer.git
synced 2025-01-11 04:25:08 +00:00
54 lines
985 B
JavaScript
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');
|
|
}
|
|
};
|
|
|