"use strict"; /** * Created by Martin on 09/02/2016. */ var log4js = require('log4js'); var logger = log4js.getLogger(); var mqttConnect; function doHeatingOn() { mqttConnect.doConnection().heatingOn(); } function doHeatingOff() { mqttConnect.doConnection().heatingOff(); } function setUseRef(ref) { mqttConnect = ref; } function getStatus() { logger.debug(mqttConnect.socketSet.getClientStatus()); } module.exports = { mqttConnect:null, socket:null, use: function (ref) { setUseRef(ref); }, turnoff: function (req, res) { doHeatingOff(); res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({})); }, turnon: function (req, res) { doHeatingOn(); res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({})); }, setsocket: function (socket) { this.socket = socket; return this; }, subscribe: function (socket) { this.socket.subscribe('Heating','HeatingDataReceived'); } };