mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
MQTT V5 - prep for 1.3.0 beta...
* MQTT IN node tidy up * remove userProperties * remove subscriptionIdentifier * MQTT OUT node tidy up * remove topicAlias * remove payloadFormatIndicator * remove subscriptionIdentifier * MQTT BROKER node tidy up * remove topicAliasMaximum * remove maximumPacketSize * remove receiveMaximum * remove userProperties
This commit is contained in:
parent
c20bab2436
commit
833ecfb1af
@ -76,15 +76,27 @@
|
||||
<option value="2">2</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-datatype"><i class="fa fa-sign-out"></i> <span data-i18n="mqtt.label.output"></span></label>
|
||||
<select id="node-input-datatype" style="width:70%;">
|
||||
<option value="auto" data-i18n="mqtt.output.auto"></option>
|
||||
<option value="buffer" data-i18n="mqtt.output.buffer"></option>
|
||||
<option value="utf8" data-i18n="mqtt.output.string"></option>
|
||||
<option value="json" data-i18n="mqtt.output.json"></option>
|
||||
<option value="base64" data-i18n="mqtt.output.base64"></option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- FUTURE
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-input-userProperties"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.userProperties"></span></label>
|
||||
<input id="node-input-userPropertiesType" type="hidden">
|
||||
<input type="text" id="node-input-userProperties" style="width: 70%;" data-i18n="[placeholder]mqtt.label.userProperties" placeholder="">
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- FUTURE
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-input-subscriptionIdentifier" class="mqtt-form-row-col1"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.subscriptionIdentifier"></span></label>
|
||||
<input type="number" min="0" max="268435455" id="node-input-subscriptionIdentifier" class="mqtt-form-row-col1" >
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="form-row mqtt-flags-row mqtt5">
|
||||
<label for="node-input-nl" ><i class="fa fa-flag"></i> <span data-i18n="mqtt.label.flags">Flags</span></label>
|
||||
<div class="mqtt-flags">
|
||||
@ -110,16 +122,6 @@
|
||||
<option value="2" data-i18n="mqtt.label.rh2"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-datatype"><i class="fa fa-sign-out"></i> <span data-i18n="mqtt.label.output"></span></label>
|
||||
<select id="node-input-datatype" style="width:70%;">
|
||||
<option value="auto" data-i18n="mqtt.output.auto"></option>
|
||||
<option value="buffer" data-i18n="mqtt.output.buffer"></option>
|
||||
<option value="utf8" data-i18n="mqtt.output.string"></option>
|
||||
<option value="json" data-i18n="mqtt.output.json"></option>
|
||||
<option value="base64" data-i18n="mqtt.output.base64"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||
@ -135,9 +137,9 @@
|
||||
qos: {value: "2"},
|
||||
datatype: {value:"auto",required:true},
|
||||
broker: {type:"mqtt-broker", required:true},
|
||||
userPropertiesType: {value:"json"},
|
||||
userProperties: {value:"{}"},
|
||||
subscriptionIdentifier: {value:0},
|
||||
// userProperties: {value:"userProperties"},
|
||||
// userPropertiesType: {value:"none"},
|
||||
// subscriptionIdentifier: {value:0},
|
||||
nl: {value:false},
|
||||
rap: {value:true},
|
||||
rh: {value:0},
|
||||
@ -168,11 +170,12 @@
|
||||
if (this.datatype === undefined) {
|
||||
$("#node-input-datatype").val("auto");
|
||||
}
|
||||
$("#node-input-userProperties").typedInput({
|
||||
default: "json",
|
||||
types:['json','flow','global'],
|
||||
typeField: $("#node-input-userPropertiesType")
|
||||
});
|
||||
// FUTURE
|
||||
// $("#node-input-userProperties").typedInput({
|
||||
// default: "none",
|
||||
// types:[{ value: 'none', label: 'None', hasValue: false },'flow','global','json'],
|
||||
// typeField: $("#node-input-userPropertiesType")
|
||||
// });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@ -203,33 +206,38 @@
|
||||
<option value="true" data-i18n="mqtt.true"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-input-userProperties"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.userProperties"></span></label>
|
||||
<input id="node-input-userPropertiesType" type="hidden">
|
||||
<input type="text" id="node-input-userProperties" style="width: 70%;" data-i18n="[placeholder]mqtt.label.userProperties" placeholder="">
|
||||
</div>
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-input-responseTopic"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.responseTopic"></span></label>
|
||||
<input type="text" id="node-input-responseTopic" data-i18n="[placeholder]mqtt.label.responseTopic" placeholder="">
|
||||
<input id="node-input-responseTopicType" type="hidden">
|
||||
<input type="text" id="node-input-responseTopic" style="width: 70%;" data-i18n="[placeholder]mqtt.label.responseTopic" placeholder="">
|
||||
</div>
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-input-correlationData"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.correlationData"></span></label>
|
||||
<input id="node-input-correlationDataType" type="hidden">
|
||||
<input type="text" id="node-input-correlationData" style="width: 70%;" data-i18n="[placeholder]mqtt.label.correlationData" placeholder="">
|
||||
</div>
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-input-userProperties"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.userProperties"></span></label>
|
||||
<input id="node-input-userPropertiesType" type="hidden">
|
||||
<input type="text" id="node-input-userProperties" style="width: 70%;" data-i18n="[placeholder]mqtt.label.userProperties" placeholder="">
|
||||
</div>
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-input-contentType"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.contentType"></span></label>
|
||||
<input type="text" id="node-input-contentType" data-i18n="[placeholder]mqtt.label.contentType" placeholder="">
|
||||
<input id="node-input-contentTypeType" type="hidden">
|
||||
<input type="text" id="node-input-contentType" style="width: 70%;" data-i18n="[placeholder]mqtt.label.contentType" placeholder="">
|
||||
</div>
|
||||
|
||||
<div class="form-row mqtt-form-row-cols2 mqtt5">
|
||||
<label for="node-input-messageExpiryInterval" class="mqtt-form-row-col1"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.messageExpiryInterval"></span></label>
|
||||
<input type="number" min="0" id="node-input-messageExpiryInterval" class="mqtt-form-row-col1" >
|
||||
<input id="node-input-messageExpiryIntervalType" type="hidden">
|
||||
<input id="node-input-messageExpiryInterval" style="width: 70%;" class="mqtt-form-row-col1" >
|
||||
|
||||
<!-- FUTURE
|
||||
<label for="node-input-topicAlias" class="mqtt-form-row-col2"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.topicAlias">Alias</span></label>
|
||||
<input type="number" min="0" id="node-input-topicAlias" class="mqtt-form-row-col2" >
|
||||
<input type="number" min="0" id="node-input-topicAlias" class="mqtt-form-row-col2" > -->
|
||||
</div>
|
||||
|
||||
<!-- FUTURE
|
||||
<div class="form-row mqtt-form-row-cols2 mqtt5">
|
||||
<label for="node-input-subscriptionIdentifier" class="mqtt-form-row-col1"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.subscriptionIdentifier"></span></label>
|
||||
<input type="number" min="0" max="268435455" id="node-input-subscriptionIdentifier" class="mqtt-form-row-col1" >
|
||||
@ -240,7 +248,7 @@
|
||||
<option value="false" data-i18n="mqtt.label.payloadFormatIndicatorFalse"></option>
|
||||
<option value="true" data-i18n="mqtt.label.payloadFormatIndicatorTrue"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||
@ -257,16 +265,19 @@
|
||||
topic: {value:""},
|
||||
qos: {value:""},
|
||||
retain: {value:""},
|
||||
responseTopic: {value:""},
|
||||
contentType: {value:""},
|
||||
responseTopic: {value:"responseTopic"},
|
||||
responseTopicType: {value:'none'},
|
||||
contentType: {value:"contentType"},
|
||||
contentTypeType: {value:'none'},
|
||||
userProperties: {value:'userProperties'},
|
||||
userPropertiesType: {value:'msg'},
|
||||
userPropertiesType: {value:'none'},
|
||||
correlationData: {value:'correlationData'},
|
||||
correlationDataType: {value:'msg'},
|
||||
topicAlias: {value:0},
|
||||
messageExpiryInterval: {value:0},
|
||||
payloadFormatIndicator: {value:false},
|
||||
subscriptionIdentifier: {value:0},
|
||||
correlationDataType: {value:'none'},
|
||||
messageExpiryInterval: {value:"messageExpiryInterval"},
|
||||
messageExpiryIntervalType: {value:'none'},
|
||||
// FUTURE topicAlias: {value:0},
|
||||
// FUTURE payloadFormatIndicator: {value:false},
|
||||
// FUTURE subscriptionIdentifier: {value:0},
|
||||
broker: {type:"mqtt-broker", required:true}
|
||||
},
|
||||
color:"#d8bfd8",
|
||||
@ -275,10 +286,13 @@
|
||||
icon: "bridge.svg",
|
||||
align: "right",
|
||||
label: function() {
|
||||
return this.name||this.topic||(this.topicAlias ? "@"+this.topicAlias : "mqtt");
|
||||
return this.name||this.topic||"mqtt";
|
||||
// FUTURE return this.name||this.topic||(this.topicAlias ? "@"+this.topicAlias : "mqtt");
|
||||
},
|
||||
oneditprepare: function() {
|
||||
$("#node-input-broker").change(function(d){
|
||||
var typedInputNoneOpt = { value: 'none', label: 'None', hasValue: false };
|
||||
|
||||
function showHideDynamicFields() {
|
||||
var confNode = RED.nodes.node($("#node-input-broker").val());
|
||||
var v5 = confNode && confNode.protocolVersion == "5";
|
||||
if(v5) {
|
||||
@ -286,17 +300,99 @@
|
||||
} else {
|
||||
$("div.form-row.mqtt5").hide();
|
||||
}
|
||||
});
|
||||
$("#node-input-correlationData").typedInput({
|
||||
default: "none",
|
||||
types:[{ value:"none", label: "None", hasValue:false },'bin','msg','flow','global'],
|
||||
var t = $("#node-input-responseTopic").typedInput("type");
|
||||
if (t == 'none') {
|
||||
$("#node-input-correlationData").parent().hide();
|
||||
} else {
|
||||
$("#node-input-correlationData").parent().show();
|
||||
}
|
||||
}
|
||||
|
||||
$("#node-input-broker").change(function(d){
|
||||
showHideDynamicFields();
|
||||
});
|
||||
|
||||
var responseTopicTI = $("#node-input-responseTopic").typedInput({
|
||||
default: 'none',
|
||||
types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'str'],
|
||||
typeField: $("#node-input-responseTopicType")
|
||||
});
|
||||
|
||||
var correlationDataTI = $("#node-input-correlationData").typedInput({
|
||||
default: 'none',
|
||||
types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'bin'],
|
||||
typeField: $("#node-input-correlationDataType")
|
||||
});
|
||||
//show / hide correlation data depending on responseTopic
|
||||
responseTopicTI.on("change", function() {
|
||||
showHideDynamicFields();
|
||||
});
|
||||
responseTopicTI.triggerHandler("change");
|
||||
|
||||
$("#node-input-userProperties").typedInput({
|
||||
default: "msg",
|
||||
types:['msg','flow','global','json'],
|
||||
default: 'none',
|
||||
types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'json'],
|
||||
typeField: $("#node-input-userPropertiesType")
|
||||
});
|
||||
|
||||
$("#node-input-messageExpiryInterval").typedInput({
|
||||
default: 'none',
|
||||
types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'num'],
|
||||
typeField: $("#node-input-messageExpiryIntervalType")
|
||||
});
|
||||
|
||||
var makeTypedInputOpt = function(value, label, tooltip){
|
||||
return {
|
||||
label: label,
|
||||
value: value || label,
|
||||
title: tooltip,
|
||||
multiple: true
|
||||
}
|
||||
}
|
||||
//TODO: i18n
|
||||
var commonOpts = [
|
||||
makeTypedInputOpt("application/gzip", "application/gzip", "GZip Compressed Archive"),
|
||||
makeTypedInputOpt("application/json", "application/json", "JSON format"),
|
||||
makeTypedInputOpt("application/octet-stream", "application/octet-stream", "Any kind of binary data"),
|
||||
makeTypedInputOpt("application/ogg", "application/ogg", "OGG"),
|
||||
makeTypedInputOpt("application/pdf", "application/pdf", "Adobe Portable Document Format (PDF)"),
|
||||
makeTypedInputOpt("application/zip", "application/zip", "ZIP archive"),
|
||||
makeTypedInputOpt("audio/aac", "audio/aac", "AAC audio"),
|
||||
makeTypedInputOpt("audio/midi", "audio/midi", "Musical Instrument Digital Interface (MIDI)"),
|
||||
makeTypedInputOpt("audio/x-midi", "audio/x-midi", "Musical Instrument Digital Interface (MIDI)"),
|
||||
makeTypedInputOpt("audio/mpeg", "audio/mpeg", "MP3 audio"),
|
||||
makeTypedInputOpt("audio/ogg", "audio/ogg", "OGG audio"),
|
||||
makeTypedInputOpt("audio/wav", "audio/wav", "Waveform Audio Format"),
|
||||
makeTypedInputOpt("audio/webm", "audio/webm", "WEBM audio"),
|
||||
makeTypedInputOpt("image/bmp", "image/bmp", "Windows OS/2 Bitmap Graphics"),
|
||||
makeTypedInputOpt("image/gif", "image/gif", "Graphics Interchange Format (GIF)"),
|
||||
makeTypedInputOpt("image/jpeg", "image/jpeg", "JPEG images"),
|
||||
makeTypedInputOpt("image/png", "image/png", "Portable Network Graphics"),
|
||||
makeTypedInputOpt("image/tiff", "image/tiff", "Tagged Image File Format (TIFF)"),
|
||||
makeTypedInputOpt("image/webp", "image/webp", "WEBP image"),
|
||||
makeTypedInputOpt("text/csv", "text/csv", "Comma-separated values (CSV)"),
|
||||
makeTypedInputOpt("text/html", "text/html", "HyperText Markup Language (HTML)"),
|
||||
makeTypedInputOpt("text/plain", "text/plain", "Text, (generally ASCII or ISO 8859-n)"),
|
||||
makeTypedInputOpt("video/mpeg", "video/mpeg", "MPEG Video"),
|
||||
makeTypedInputOpt("video/ogg", "video/ogg", "OGG video"),
|
||||
makeTypedInputOpt("video/webm", "video/webm", "WEBM video"),
|
||||
];
|
||||
$("#node-input-contentType").typedInput({
|
||||
default: 'none',
|
||||
types: [
|
||||
typedInputNoneOpt,
|
||||
{
|
||||
value: "preset",
|
||||
label: "Preset",
|
||||
title: "Preset Content-Types",
|
||||
icon: "fa fa-list",
|
||||
showLabel: false,
|
||||
multiple: false,
|
||||
options: commonOpts,
|
||||
default: "application/json"
|
||||
}, 'msg', 'flow', 'global', 'str'],
|
||||
typeField: $("#node-input-contentTypeType")
|
||||
});
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
@ -353,7 +449,8 @@
|
||||
<option value="4" data-i18n="mqtt.label.protocolVersion4"></option>
|
||||
<option value="5" data-i18n="mqtt.label.protocolVersion5"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- FUTURE
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-config-input-userProperties"><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.userProperties"></span></label>
|
||||
<input id="node-config-input-userPropertiesType" type="hidden">
|
||||
@ -370,7 +467,7 @@
|
||||
<div class="form-row mqtt5">
|
||||
<label for="node-config-input-receiveMaximum" ><i class="fa fa-tag"></i> <span data-i18n="mqtt.label.receiveMaximum"></span></label>
|
||||
<input type="number" min="0" id="node-config-input-receiveMaximum">
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div id="mqtt-broker-tab-security" style="display:none">
|
||||
<div class="form-row">
|
||||
@ -500,11 +597,11 @@
|
||||
willRetain: {value:false},
|
||||
willPayload: {value:""},
|
||||
sessionExpiryInterval: {value:0},
|
||||
topicAliasMaximum: {value:0},
|
||||
maximumPacketSize: {value:0},
|
||||
receiveMaximum: {value:0},
|
||||
userPropertiesType: {value:"json"},
|
||||
userProperties: {value:"{}"},
|
||||
// FUTURE topicAliasMaximum: {value:0},
|
||||
// FUTURE maximumPacketSize: {value:0},
|
||||
// FUTURE receiveMaximum: {value:0},
|
||||
// FUTURE userPropertiesType: {value:"json"},
|
||||
// FUTURE userProperties: {value:"{}"},
|
||||
},
|
||||
credentials: {
|
||||
user: {type:"text"},
|
||||
@ -607,11 +704,12 @@
|
||||
updateSessionExpiryIntervalVisibility();
|
||||
});
|
||||
$("#node-config-input-protocolVersion").val(this.protocolVersion);
|
||||
$("#node-config-input-userProperties").typedInput({
|
||||
default: "json",
|
||||
types:['json'],
|
||||
typeField: $("#node-config-input-userPropertiesType")
|
||||
});
|
||||
// FUTURE
|
||||
// $("#node-config-input-userProperties").typedInput({
|
||||
// default: "json",
|
||||
// types:['json'],
|
||||
// typeField: $("#node-config-input-userPropertiesType")
|
||||
// });
|
||||
if (typeof this.keepalive === 'undefined') {
|
||||
this.keepalive = 15;
|
||||
$("#node-config-input-keepalive").val(this.keepalive);
|
||||
|
@ -140,7 +140,7 @@ module.exports = function(RED) {
|
||||
if(!dst) return;
|
||||
if (src && dst) {
|
||||
var buf = src[propName];
|
||||
if (buf && typeof Buffer.isBuffer(buf)) {
|
||||
if (buf && typeof Buffer.isBuffer(buf)) {
|
||||
dst[propName] = Buffer.from(buf);
|
||||
}
|
||||
} else {
|
||||
@ -432,7 +432,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
});
|
||||
node.client.on("reconnect", function() {
|
||||
debug('MQTTBrokerNode reconnect event', packet); //TODO: remove
|
||||
debug('MQTTBrokerNode reconnect event'); //TODO: remove
|
||||
for (var id in node.users) {
|
||||
if (node.users.hasOwnProperty(id)) {
|
||||
node.users[id].status({fill:"yellow",shape:"ring",text:"node-red:common.status.connecting"});
|
||||
@ -560,15 +560,16 @@ module.exports = function(RED) {
|
||||
if(node.options.protocolVersion == 5) {
|
||||
options.properties = options.properties || {};
|
||||
setStrProp(msg, options.properties, "responseTopic");
|
||||
setStrProp(msg, options.properties, "contentType");
|
||||
setIntProp(msg, options.properties, "topicAlias", 1, node.serverProperties.topicAliasMaximum || 0);
|
||||
setIntProp(msg, options.properties, "subscriptionIdentifier", 1, 268435455);
|
||||
setIntProp(msg, options.properties, "messageExpiryInterval", 0);
|
||||
setBoolProp(msg, options.properties, "payloadFormatIndicator");
|
||||
setUserProperties(msg.userProperties, options.properties);
|
||||
setBufferProp(msg, options.properties, "correlationData");
|
||||
setStrProp(msg, options.properties, "contentType");
|
||||
setIntProp(msg, options.properties, "messageExpiryInterval", 0);
|
||||
setUserProperties(msg.userProperties, options.properties);
|
||||
setIntProp(msg, options.properties, "topicAlias", 1, node.serverProperties.topicAliasMaximum || 0);
|
||||
setBoolProp(msg, options.properties, "payloadFormatIndicator");
|
||||
//FUTURE setIntProp(msg, options.properties, "subscriptionIdentifier", 1, 268435455);
|
||||
}
|
||||
debug(`MQTTBrokerNode:${node.id}: publish - sending payload to ${msg.topic ? msg.topic : (msg.topicAlias ? 'topicAlias-'+msg.topicAlias : '???') } `, options);//TODO: remove
|
||||
// debug(`MQTTBrokerNode:${node.id}: publish - sending payload to ${msg.topic ? msg.topic : (msg.topicAlias ? 'topicAlias-'+msg.topicAlias : '???') } `, options);//TODO: remove
|
||||
debug(`MQTTBrokerNode:${node.id}: publish - sending payload to ${msg.topic} `, options);//TODO: remove
|
||||
node.client.publish(msg.topic, msg.payload, options, function(err) {
|
||||
if(err) node.error(err,msg);//catch errors
|
||||
done && done();
|
||||
@ -669,14 +670,14 @@ module.exports = function(RED) {
|
||||
if(v5 && packet.properties) {
|
||||
//msg.properties = packet.properties;
|
||||
setStrProp(packet.properties, msg, "responseTopic");
|
||||
setBufferProp(packet.properties, msg, "correlationData");
|
||||
setStrProp(packet.properties, msg, "contentType");
|
||||
setIntProp(packet.properties, msg, "topicAlias", 1, node.brokerConn.serverProperties.topicAliasMaximum || 0);
|
||||
setIntProp(packet.properties, msg, "subscriptionIdentifier", 1, 268435455);
|
||||
// setIntProp(packet.properties, msg, "topicAlias", 1, node.brokerConn.serverProperties.topicAliasMaximum || 0);
|
||||
// setIntProp(packet.properties, msg, "subscriptionIdentifier", 1, 268435455);
|
||||
setIntProp(packet.properties, msg, "messageExpiryInterval", 0);
|
||||
setBoolProp(packet.properties, msg, "payloadFormatIndicator");
|
||||
setStrProp(packet.properties, msg, "reasonString");
|
||||
setUserProperties(packet.properties.userProperties, msg);
|
||||
setBufferProp(packet.properties, msg, "correlationData");
|
||||
}
|
||||
if ((node.brokerConn.broker === "localhost")||(node.brokerConn.broker === "127.0.0.1")) {
|
||||
msg._topic = topic;
|
||||
@ -709,15 +710,18 @@ module.exports = function(RED) {
|
||||
this.retain = n.retain;
|
||||
this.broker = n.broker;
|
||||
this.responseTopic = n.responseTopic;//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901114
|
||||
this.responseTopicType = n.responseTopicType;
|
||||
this.correlationData = n.correlationData;//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901115
|
||||
this.correlationDataType = n.correlationDataType;
|
||||
this.contentType = n.contentType;//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901118
|
||||
this.topicAlias = n.topicAlias; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113
|
||||
this.contentTypeType = n.contentTypeType;
|
||||
this.messageExpiryInterval = n.messageExpiryInterval; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901112
|
||||
this.payloadFormatIndicator = n.payloadFormatIndicator; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901111
|
||||
this.subscriptionIdentifier = n.subscriptionIdentifier;//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901117
|
||||
this.messageExpiryIntervalType = n.messageExpiryIntervalType;
|
||||
this.userProperties = n.userProperties;//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116
|
||||
this.userPropertiesType = n.userPropertiesType;
|
||||
// this.topicAlias = n.topicAlias; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901113
|
||||
// this.payloadFormatIndicator = n.payloadFormatIndicator; //https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901111
|
||||
// this.subscriptionIdentifier = n.subscriptionIdentifier;//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901117
|
||||
|
||||
this.brokerConn = RED.nodes.getNode(this.broker);
|
||||
var node = this;
|
||||
@ -740,26 +744,35 @@ module.exports = function(RED) {
|
||||
let msgPropOverride = function(propName) { if(node[propName]) { msg[propName] = node[propName]; } }
|
||||
msgPropOverride("topic");
|
||||
if(v5) {
|
||||
if(node.userProperties) {
|
||||
if(node.userProperties && node.userPropertiesType !== "none") {
|
||||
let userProperties = RED.util.evaluateNodeProperty(node.userProperties, node.userPropertiesType, node, msg);
|
||||
if(userProperties) msg.userProperties = userProperties;
|
||||
}
|
||||
if(node.responseTopic && node.responseTopicType !== "none") {
|
||||
let responseTopic = RED.util.evaluateNodeProperty(node.responseTopic, node.responseTopicType, node, msg);
|
||||
if(responseTopic) msg.responseTopic = responseTopic;
|
||||
}
|
||||
if(node.correlationData && node.correlationDataType !== "none") {
|
||||
let correlationData = RED.util.evaluateNodeProperty(node.correlationData, node.correlationDataType, node, msg);
|
||||
if(correlationData) msg.correlationData = correlationData;
|
||||
}
|
||||
//Next, update/override the msg.xxxx properties from config
|
||||
if(node.contentType && node.contentTypeType !== "none") {
|
||||
let contentType = RED.util.evaluateNodeProperty(node.contentType, node.contentTypeType, node, msg);
|
||||
if(contentType) msg.contentType = contentType;
|
||||
}
|
||||
if(node.messageExpiryInterval && node.messageExpiryIntervalType !== "none") {
|
||||
let messageExpiryInterval = RED.util.evaluateNodeProperty(node.messageExpiryInterval, node.messageExpiryIntervalType, node, msg);
|
||||
if(messageExpiryInterval) msg.messageExpiryInterval = messageExpiryInterval;
|
||||
}
|
||||
//Next, update/override the msg.xxxx properties from node config
|
||||
//TODO: Should we be expecting msg.properties.xxxx instead of msg.xxxx?
|
||||
msgPropOverride("responseTopic");
|
||||
msgPropOverride("contentType");
|
||||
msgPropOverride("topicAlias");
|
||||
msgPropOverride("messageExpiryInterval");
|
||||
msgPropOverride("payloadFormatIndicator");
|
||||
msgPropOverride("subscriptionIdentifier");
|
||||
setIntProp(msg,msg,"topicAlias");
|
||||
setIntProp(msg,msg,"messageExpiryInterval");
|
||||
setBoolProp(msg,msg,"payloadFormatIndicator");
|
||||
setIntProp(msg,msg,"subscriptionIdentifier");
|
||||
// setStrProp(node,msg,"responseTopic");
|
||||
// setBufferProp(node,msg,"correlationData");
|
||||
// setStrProp(node,msg,"contentType");
|
||||
// setIntProp(node,msg,"messageExpiryInterval");
|
||||
//FUTURE setStrProp(node,msg,"topicAlias");
|
||||
//FUTURE setBoolProp(node,msg,"payloadFormatIndicator");
|
||||
//FUTURE setIntProp(node,msg,"subscriptionIdentifier");
|
||||
}
|
||||
if ( msg.hasOwnProperty("payload")) {
|
||||
let topicOK = msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "");
|
||||
|
Loading…
Reference in New Issue
Block a user