mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Debug to status option (#1499)
* Let debug optionally target the status line (32 chars only) * Add batching of messages to debug ws comms * let Debug handle simple case of NaN would also close #1530 * Fixup debug tests for batch comms (no new tests yet) * mixup comms/api test to match new batch mode (no new tests) * Add test for NaN being sent OK. * redo original fix to padding / labels for new debug options * fix debug test (re-add fix from #1444) * Fix up merge issues in debug tests
This commit is contained in:
committed by
Nick O'Leary
parent
7bd8d8c3ae
commit
7b1787fdbb
@@ -63,7 +63,7 @@ function start() {
|
||||
// https://github.com/websockets/ws/pull/632
|
||||
// that is fixed in the 1.x release of the ws module
|
||||
// that we cannot currently pickup as it drops node 0.10 support
|
||||
perMessageDeflate: false
|
||||
//perMessageDeflate: false
|
||||
});
|
||||
|
||||
wsServer.on('connection',function(ws) {
|
||||
@@ -189,15 +189,27 @@ function publish(topic,data,retain) {
|
||||
}
|
||||
}
|
||||
|
||||
var stack = [];
|
||||
var ok2tx = true;
|
||||
function publishTo(ws,topic,data) {
|
||||
var msg = JSON.stringify({topic:topic,data:data});
|
||||
try {
|
||||
ws.send(msg);
|
||||
} catch(err) {
|
||||
removeActiveConnection(ws);
|
||||
removePendingConnection(ws);
|
||||
log.warn(log._("comms.error-send",{message:err.toString()}));
|
||||
if (topic && data) { stack.push({topic:topic,data:data}); }
|
||||
|
||||
if (ok2tx && (stack.length > 0)) {
|
||||
ok2tx = false;
|
||||
try {
|
||||
ws.send(JSON.stringify(stack));
|
||||
} catch(err) {
|
||||
removeActiveConnection(ws);
|
||||
removePendingConnection(ws);
|
||||
log.warn(log._("comms.error-send",{message:err.toString()}));
|
||||
}
|
||||
stack = [];
|
||||
var txtout = setTimeout(function() {
|
||||
ok2tx = true;
|
||||
publishTo(ws);
|
||||
}, 50); // TODO: OK so a 50mS update rate should prob not be hard-coded
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function handleRemoteSubscription(ws,topic) {
|
||||
|
Reference in New Issue
Block a user