mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-07 23:03:38 +00:00
Define variables before use
This commit is contained in:
+1
-1
@@ -237,7 +237,6 @@ infoUpdate = function (device, param, value) {
|
||||
};
|
||||
module.exports.infoUpdate = infoUpdate;
|
||||
|
||||
setInterval(heartbeat, 100);
|
||||
function heartbeat() {
|
||||
for (let i in devices) {
|
||||
const device = devices[i];
|
||||
@@ -257,3 +256,4 @@ function heartbeat() {
|
||||
}
|
||||
}
|
||||
}
|
||||
setInterval(heartbeat, 100);
|
||||
|
||||
+23
-23
@@ -13,6 +13,29 @@ const PLUGINS = require('./plugins.js');
|
||||
let searching = false;
|
||||
let allServers = false;
|
||||
|
||||
// from local-devices library
|
||||
function getServers() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
const result = [];
|
||||
|
||||
for (const key in interfaces) {
|
||||
const addresses = interfaces[key];
|
||||
for (let i = addresses.length; i--; ) {
|
||||
const address = addresses[i];
|
||||
if (address.family === 'IPv4' && !address.internal) {
|
||||
const subnet = ip.subnet(address.address, address.netmask);
|
||||
let current = ip.toLong(subnet.firstAddress);
|
||||
const last = ip.toLong(subnet.lastAddress) - 1;
|
||||
while (current++ < last) result.push(ip.fromLong(current));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const searchSockets = [];
|
||||
|
||||
searchAll = function () {
|
||||
if (searching) {
|
||||
return true;
|
||||
@@ -166,27 +189,6 @@ TCPtest = function (ip, pluginType, plugin) {
|
||||
});
|
||||
};
|
||||
|
||||
// from local-devices library
|
||||
function getServers() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
const result = [];
|
||||
|
||||
for (const key in interfaces) {
|
||||
const addresses = interfaces[key];
|
||||
for (let i = addresses.length; i--; ) {
|
||||
const address = addresses[i];
|
||||
if (address.family === 'IPv4' && !address.internal) {
|
||||
const subnet = ip.subnet(address.address, address.netmask);
|
||||
let current = ip.toLong(subnet.firstAddress);
|
||||
const last = ip.toLong(subnet.lastAddress) - 1;
|
||||
while (current++ < last) result.push(ip.fromLong(current));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
findOnlineDevices = function () {
|
||||
const allInterfaces = os.networkInterfaces();
|
||||
const validInterfaces = [];
|
||||
@@ -287,8 +289,6 @@ const xAirMessage = Buffer.from([0x2f, 0x78, 0x69, 0x6e, 0x66, 0x6f]);
|
||||
const serverUDP = dgram.createSocket('udp4');
|
||||
const serverUDP2 = dgram.createSocket('udp4');
|
||||
|
||||
const searchSockets = [];
|
||||
|
||||
newSearchUDP = function (pluginType, plugin) {
|
||||
const i = searchSockets.push(dgram.createSocket('udp4')) - 1;
|
||||
searchSockets[i].bind(plugin.searchOptions.listenPort, () => {
|
||||
|
||||
Reference in New Issue
Block a user