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

node-red-contrib-df1-gateway

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-df1-gateway - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

4

package.json
{
"name": "node-red-contrib-df1-gateway",
"version": "1.0.6",
"version": "1.0.7",
"description": "",

@@ -33,4 +33,4 @@ "main": "df1-gateway.js",

"optionalDependencies": {
"@protocols/node-df1-gateway": "^1.0.1"
"@protocols/node-df1-gateway": "^1.0.2"
}
}

@@ -20,28 +20,65 @@ try {

node.df1 = RED.nodes.getNode(config.df1);
if (!node.df1) {
return node.error(RED._("df1.error.missingconfig"));
const configNode = RED.nodes.getNode(config.endpoint);
if (!configNode) {
return this.error(RED._("df1.error.missingconfig"));
}
const server = new Gateway({productName: config.nameGateway})
const endpoint = RED.nodes.getNode(config.endpoint);
let df1 = null;
let that = this;
let serverClosed = true;
endpoint.on('connected', () => {
const session = endpoint.getDf1Session()
if(session) registerSession(session);
});
let _reconnectTimeout = null;
endpoint.on('error', () => {
const session = endpoint.getDf1Session();
if(session) unRegisterSession(session);
});
function connect() {
endpoint.on('timeout', () => {
const session = endpoint.getDf1Session();
if(session) unRegisterSession(session);
})
if (_reconnectTimeout !== null) {
clearTimeout(_reconnectTimeout);
_reconnectTimeout = null;
};
df1 = configNode.df1Endpoint();
if(df1){
df1.on('connected',registerSession);
df1.on('error',unRegisterSession);
df1.on('timeout',unRegisterSession);
df1.on('disconnect',onDisconnect);
}else{
onDisconnect();
}
}
function onDisconnect() {
if(df1 !== null){
df1.removeListener('connected',registerSession);
df1.removeListener('error',unRegisterSession);
df1.removeListener('timeout',unRegisterSession);
df1.removeListener('disconnect',onDisconnect);
unRegisterSession();
df1 = null;
};
if (!_reconnectTimeout) {
_reconnectTimeout = setTimeout(connect, 5000);
};
}
function getDf1Session() {
const df1protocol = df1.df1Protocol;
if(df1protocol) return df1protocol.dataLinkSession;
}
function registerSession() {
const session = getDf1Session();
if(session) server.registerDf1(session);
};
function unRegisterSession() {
const session = getDf1Session();
if(session) server.unRegisterDf1(session);
};
server.on('error',(err) => {

@@ -66,10 +103,2 @@ if (serverClosed == false) {

function registerSession(df1) {
server.registerDf1(df1);
};
function unRegisterSession(df1) {
server.unRegisterDf1(df1);
};
function closeServer(){

@@ -85,2 +114,4 @@ serverClosed = true;

};
connect();
};

@@ -87,0 +118,0 @@

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