mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add RED.util.generateId and ensure HTTP node adds proper id
This commit is contained in:
@@ -96,10 +96,6 @@ Node.prototype.close = function() {
|
||||
}
|
||||
};
|
||||
|
||||
function constructUniqueIdentifier() {
|
||||
return (1+Math.random()*4294967295).toString(16);
|
||||
}
|
||||
|
||||
Node.prototype.send = function(msg) {
|
||||
var msgSent = false;
|
||||
var node;
|
||||
@@ -112,7 +108,7 @@ Node.prototype.send = function(msg) {
|
||||
// TODO: pre-load flows.get calls - cannot do in constructor
|
||||
// as not all nodes are defined at that point
|
||||
if (!msg._msgid) {
|
||||
msg._msgid = constructUniqueIdentifier();
|
||||
msg._msgid = redUtil.generateId();
|
||||
}
|
||||
this.metric("send",msg);
|
||||
node = flows.get(this._wire);
|
||||
@@ -171,7 +167,7 @@ Node.prototype.send = function(msg) {
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (!sentMessageId) {
|
||||
sentMessageId = constructUniqueIdentifier();
|
||||
sentMessageId = redUtil.generateId();
|
||||
}
|
||||
this.metric("send",{_msgid:sentMessageId});
|
||||
|
||||
@@ -190,7 +186,7 @@ Node.prototype.receive = function(msg) {
|
||||
msg = {};
|
||||
}
|
||||
if (!msg._msgid) {
|
||||
msg._msgid = constructUniqueIdentifier();
|
||||
msg._msgid = redUtil.generateId();
|
||||
}
|
||||
this.metric("receive",msg);
|
||||
try {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2014 IBM Corp.
|
||||
* Copyright 2014, 2015 IBM Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
var clone = require("clone");
|
||||
|
||||
function generateId() {
|
||||
return (1+Math.random()*4294967295).toString(16);
|
||||
}
|
||||
|
||||
function ensureString(o) {
|
||||
if (Buffer.isBuffer(o)) {
|
||||
return o.toString();
|
||||
@@ -103,5 +107,6 @@ module.exports = {
|
||||
ensureString: ensureString,
|
||||
ensureBuffer: ensureBuffer,
|
||||
cloneMessage: cloneMessage,
|
||||
compareObjects: compareObjects
|
||||
compareObjects: compareObjects,
|
||||
generateId: generateId
|
||||
};
|
||||
|
Reference in New Issue
Block a user