No Description

wifi_routers.js 1.0KB

    var logger = require('winston'); var http = require('http'); var wifi_routers = [ { title : "Satelite Link", status: "Unkown", url: "http://192.168.0.1/", device: "HT2000" }, { title : "Main Router", status: "Unkown", url: "http://192.168.100.1/", device: "Wireless N 300M" }, { title : "Repeater 1", status: "Unkown", url: "http://192.168.100.100/", device: "300M Wireless N Nano Router" } ] module.exports.start = function(){ logger.info("Starting wifi routers controller module"); setInterval(function () { checkURL(wifi_routers[0].url, 0); checkURL(wifi_routers[1].url, 1); checkURL(wifi_routers[2].url, 2); }, 60000); } module.exports.monitor = function(socket, channel){ socket.on('wifi_routers_update', function (data) { socket.emit("wifi_routers", wifi_routers); }); } var checkURL = function(url, n){ http.get(url, function (res) { wifi_routers[n].status = "Active" }).on('error', function(e) { wifi_routers[n].status = "Inactive" });; }