Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## node-red-contrib-letsfiware-NGSI v0.4.2

- Fix shared buffer in entities node (#30)

## node-red-contrib-letsfiware-NGSI v0.4.0-next

- Update copyright date (#28)
Expand Down Expand Up @@ -30,4 +34,4 @@

## node-red-contrib-NGSI-LD v0.0.1 - 13 April, 2023

- Initial release
- Initial release
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-ngsi-ld",
"version": "0.4.1",
"version": "0.4.2",
"description": "Node-RED implementation for NGSI-LD",
"scripts": {
"lint": "./node_modules/eslint/bin/eslint.js --ext .json,.js src test",
Expand Down
92 changes: 46 additions & 46 deletions src/nodes/NGSI-LD/entities/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,52 +79,6 @@ const getEntities = async function (msg, param) {
param.buffer.close();
};

const nobuffering = {
node: null,
msg: null,
open: function (node, msg) {
this.node = node;
this.msg = msg;
return this;
},
send: function (entities) {
const message = Object.assign({}, this.msg);
message.payload = entities;
message.statusCode = 200;
this.node.send(message);
},
close: function () {},
out: function (entities) {
const message = Object.assign({}, this.msg);
message.payload = entities;
message.statusCode = 200;
this.node.send(message);
}
};

const buffering = {
node: null,
msg: null,
entities: [],
open: function (node, msg) {
this.node = node;
this.msg = msg;
this.entities = [];
return this;
},
send: function (entities) {
this.entities = this.entities.concat(entities);
},
close: function () {
this.msg.payload = this.entities;
this.msg.statusCode = 200;
this.node.send(this.msg);
},
out: function (entities) {
this.entities = this.entities.concat(entities);
}
};

const validateConfig = function (msg, config) {
const items = [
'atContext',
Expand Down Expand Up @@ -242,6 +196,52 @@ const createParam = function (msg, config, brokerConfig) {
return null;
}

const buffering = {
node: null,
msg: null,
entities: [],
open: function (node, msg) {
this.node = node;
this.msg = msg;
this.entities = [];
return this;
},
send: function (entities) {
this.entities = this.entities.concat(entities);
},
close: function () {
this.msg.payload = this.entities;
this.msg.statusCode = 200;
this.node.send(this.msg);
},
out: function (entities) {
this.entities = this.entities.concat(entities);
}
};

const nobuffering = {
node: null,
msg: null,
open: function (node, msg) {
this.node = node;
this.msg = msg;
return this;
},
send: function (entities) {
const message = Object.assign({}, this.msg);
message.payload = entities;
message.statusCode = 200;
this.node.send(message);
},
close: function () {},
out: function (entities) {
const message = Object.assign({}, this.msg);
message.payload = entities;
message.statusCode = 200;
this.node.send(message);
}
};

param.buffer = param.config.buffering ? buffering.open(this, msg) : nobuffering.open(this, msg);

return param;
Expand Down
Loading