Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-hikvision-ultimate

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-hikvision-ultimate - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

7

CHANGELOG.md

@@ -5,5 +5,8 @@ # node-red-contrib-hikvision-ultimate

<p>
<b>Version 0.0.1</b> November 2020<br/>
<b>Version 0.0.2 BETA</b> November 2020<br/>
- Added connection checks and reconnection.
</p>
<p>
<b>Version 0.0.1 BETA</b> November 2020<br/>
- First BETA
</p>
<p>

@@ -6,2 +6,3 @@

var urllib = require('urllib');
var urllibCheckConnection = require('urllib');
var xml2js = require('xml2js').parseString;

@@ -15,66 +16,110 @@

node.nodeClients = [] // Stores the registered clients
node.timertimerConnectionCheck = setTimeout(function () { node.CheckConnection(); }, 2000);
node.alarmStreamConnected = false;
var options = {
"digestAuth": node.credentials.user + ":" + node.credentials.password,
"streaming": true,
"timeout": 5000
// 25/11/2020
//#region "Check Connection"
node.CheckConnection = () => {
// Try to find out, if the server responds.
var optionsCheck = {
"digestAuth": node.credentials.user + ":" + node.credentials.password,
"timeout": 8000
};
urllibCheckConnection.request("http://" + node.host + "/ISAPI/Event/notification/alertStream", optionsCheck, function (err, data, res) {
if (err) {
// console.log("ERROR: " + err);
// // Error connecting to the server
// node.nodeClients.forEach(oClient => {
// try {
// oClient.setNodeStatus({ fill: "red", shape: "shape", text: "Disconnected: " + errr });
// } catch (error) { }
// })
// node.alarmStreamConnected = false;
}
try {
//console.log("CHECK STATUS: " + res.statusCode);
if (res.statusCode !== 200) {
node.nodeClients.forEach(oClient => {
try {
oClient.setNodeStatus({ fill: "red", shape: "shape", text: "Disconnected. Status " + res.statusCode });
// Inform clients about disconnections.
if (node.alarmStreamConnected === true) {
oClient.send({ topic: oClient.topic || "", payload: "Disconnected" });
}
} catch (error) { }
})
node.alarmStreamConnected = false;
} else {
if (node.alarmStreamConnected === false) {
node.alarmStreamConnected = true;
node.startAlarmStream();
node.nodeClients.forEach(oClient => {
try {
oClient.setNodeStatus({ fill: "green", shape: "ring", text: "Connected" });
} catch (error) { }
})
}
}
} catch (error) {
}
node.timerConnectionCheck = setTimeout(function () { node.CheckConnection(); }, 5000);
});
};
urllib.request("http://" + node.host + "/ISAPI/Event/notification/alertStream", options, function (err, data, res) {
if (err) {
console.log("ERROR: " + err);
}
try {
console.log("STATUS: " + res.statusCode);
} catch (error) {
}
try {
console.log("HEADERS: " + res.headers);
} catch (error) {
}
try {
console.log("DATA: " + data.toString());
//#endregion
// Starts alarm stream
node.startAlarmStream = () => {
//console.log("START MAIN STREAM");
var options = {
"digestAuth": node.credentials.user + ":" + node.credentials.password,
"streaming": true,
"timeout": 5000
};
urllib.request("http://" + node.host + "/ISAPI/Event/notification/alertStream", options, function (err, data, res) {
if (err) {
console.log("MAIN ERROR: " + err);
}
try {
//console.log("MAIN STATUS: " + res.statusCode);
} catch (error) {
}
try {
//console.log("HEADERS: " + res.headers);
} catch (error) {
}
try {
//console.log("DATA: " + data.toString());
} catch (error) {
} catch (error) {
}
res.on('data', function (chunk) {
//console.log("chunk: " + chunk.toString());
var sRet = chunk.toString();
sRet = sRet.substring(sRet.indexOf("<?xml")); // Remove all before <?xml
// By xml2js
xml2js(sRet, function (err, result) {
node.nodeClients.forEach(oClient => {
oClient.send({ topic: oClient.topic || "", payload: result });
})
});
}
res.on('data', function (chunk) {
console.log("chunk: " + chunk.toString());
var sRet = chunk.toString();
sRet = sRet.substring(sRet.indexOf("<?xml")); // Remove all before <?xml
// By xml2js
xml2js(sRet, function (err, result) {
node.nodeClients.forEach(oClient => {
oClient.send({ topic: oClient.topic || "", payload: result });
})
});
res.on('end', function () {
//console.log("END");
});
});
res.on('end', function () {
console.log("END");
done();
});
};
});
this.on('input', function (msg) {
node.setNodeStatus({ fill: "green", shape: "ring", text: "banana" });
});
this.on('close', function (removed, done) {
node.on('close', function (removed, done) {
clearTimeout(node.timerConnectionCheck);
done();
});
node.on("close", function () {
})
node.addClient = (_Node) => {

@@ -86,2 +131,6 @@ // Check if node already exists

}
try {
_Node.setNodeStatus({ fill: "gray", shape: "shape", text: "Waiting for connection" });
} catch (error) {
}

@@ -104,11 +153,4 @@ }

// Used to call the status update from the config node.
node.setNodeStatus = ({ fill, shape, text }) => {
if (node.server == null) { node.status({ fill: "red", shape: "dot", text: "[NO SERVER SELECTED]" }); return; }
var dDate = new Date();
node.status({ fill: fill, shape: shape, text: text + "(" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")" });
}
}

@@ -115,0 +157,0 @@

@@ -9,2 +9,6 @@

node.setNodeStatus = ({ fill, shape, text }) => {
var dDate = new Date();
node.status({ fill: fill, shape: shape, text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")" })
}

@@ -17,4 +21,6 @@ // On each deploy, unsubscribe+resubscribe

this.on('input', function (msg) {
node.setNodeStatus({ fill: "green", shape: "ring", text: "banana" });
});
node.on("close", function (done) {

@@ -25,11 +31,4 @@ if (node.server) {

done();
})
});
function setNodeStatus({ fill, shape, text }) {
var dDate = new Date();
node.status({ fill: fill, shape: shape, text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")" })
}
}

@@ -36,0 +35,0 @@

{
"name": "node-red-contrib-hikvision-ultimate",
"version": "0.0.1",
"version": "0.0.2",
"description": "A native set of node for Hikvision Cameras, Alarms, Radars etc.",

@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)",

@@ -15,3 +15,3 @@ # node-red-contrib-hikvision-ultimate

## THIS NODESET IS IN BETA.
### THIS NODESET IS IN BETA. E' ancora brutto, ma funziona.

@@ -18,0 +18,0 @@ ## DESCRIPTION

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc