1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

merge upstream/master

This commit is contained in:
Hiroyasu Nishiyama 2018-01-29 14:44:17 +09:00
commit 18be0d6d26
3 changed files with 21 additions and 12 deletions

View File

@ -86,6 +86,9 @@ RED.notifications = (function() {
} }
n.style.display = "none"; n.style.display = "none";
if (typeof msg === "string") { if (typeof msg === "string") {
if (!/<p>/i.test(msg)) {
msg = "<p>"+msg+"</p>";
}
n.innerHTML = msg; n.innerHTML = msg;
} else { } else {
$(n).append(msg); $(n).append(msg);
@ -153,6 +156,9 @@ RED.notifications = (function() {
var nn = n; var nn = n;
return function(msg,options) { return function(msg,options) {
if (typeof msg === "string") { if (typeof msg === "string") {
if (!/<p>/i.test(msg)) {
msg = "<p>"+msg+"</p>";
}
nn.innerHTML = msg; nn.innerHTML = msg;
} else { } else {
$(nn).empty().append(msg); $(nn).empty().append(msg);

View File

@ -71,7 +71,8 @@ module.exports = function(RED) {
if (msg.hasOwnProperty("payload")) { if (msg.hasOwnProperty("payload")) {
if (msg.hasOwnProperty("parts")) { msg.parts = { parts:msg.parts }; } // push existing parts to a stack if (msg.hasOwnProperty("parts")) { msg.parts = { parts:msg.parts }; } // push existing parts to a stack
else { msg.parts = {}; } else { msg.parts = {}; }
msg.parts.id = msg._msgid; // use the existing _msgid by default. msg.parts.id = RED.util.generateId(); // generate a random id
delete msg._msgid;
if (typeof msg.payload === "string") { // Split String into array if (typeof msg.payload === "string") { // Split String into array
msg.payload = (node.remainder || "") + msg.payload; msg.payload = (node.remainder || "") + msg.payload;
msg.parts.type = "string"; msg.parts.type = "string";
@ -628,7 +629,7 @@ module.exports = function(RED) {
group.msg = msg; group.msg = msg;
var tcnt = group.targetCount; var tcnt = group.targetCount;
if (msg.hasOwnProperty("parts")) { tcnt = group.targetCount || msg.parts.count; } if (msg.hasOwnProperty("parts")) { tcnt = group.targetCount || msg.parts.count; }
if ((tcnt > 0 && group.currentCount >= tcnt) || msg.hasOwnProperty('complete')) { if ((tcnt > 0 && group.currentCount >= tcnt) || msg.hasOwnProperty('complete')) {
completeSend(partId); completeSend(partId);
} }
} catch(err) { } catch(err) {

View File

@ -70,6 +70,9 @@ function start() {
wsServer.on('connection',function(ws) { wsServer.on('connection',function(ws) {
log.audit({event: "comms.open"}); log.audit({event: "comms.open"});
var pendingAuth = (settings.adminAuth != null); var pendingAuth = (settings.adminAuth != null);
ws._nr_stack = [];
ws._nr_ok2tx = true;
if (!pendingAuth) { if (!pendingAuth) {
activeConnections.push(ws); activeConnections.push(ws);
} else { } else {
@ -190,23 +193,22 @@ function publish(topic,data,retain) {
} }
} }
var stack = [];
var ok2tx = true;
function publishTo(ws,topic,data) { function publishTo(ws,topic,data) {
if (topic && data) { stack.push({topic:topic,data:data}); } if (topic && data) {
ws._nr_stack.push({topic:topic,data:data});
if (ok2tx && (stack.length > 0)) { }
ok2tx = false; if (ws._nr_ok2tx && (ws._nr_stack.length > 0)) {
ws._nr_ok2tx = false;
try { try {
ws.send(JSON.stringify(stack)); ws.send(JSON.stringify(ws._nr_stack));
} catch(err) { } catch(err) {
removeActiveConnection(ws); removeActiveConnection(ws);
removePendingConnection(ws); removePendingConnection(ws);
log.warn(log._("comms.error-send",{message:err.toString()})); log.warn(log._("comms.error-send",{message:err.toString()}));
} }
stack = []; ws._nr_stack = [];
var txtout = setTimeout(function() { setTimeout(function() {
ok2tx = true; ws._nr_ok2tx = true;
publishTo(ws); publishTo(ws);
}, 50); // TODO: OK so a 50mS update rate should prob not be hard-coded }, 50); // TODO: OK so a 50mS update rate should prob not be hard-coded
} }