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

better handling of server properties

This commit is contained in:
Steve-Mcl 2020-12-07 12:25:51 +00:00
parent 6150ae787d
commit 6bac207611

View File

@ -379,24 +379,23 @@ module.exports = function(RED) {
node.connected = true; node.connected = true;
node.log(RED._("mqtt.state.connected",{broker:(node.clientid?node.clientid+"@":"")+node.brokerurl})); node.log(RED._("mqtt.state.connected",{broker:(node.clientid?node.clientid+"@":"")+node.brokerurl}));
if(node.options.protocolVersion == 5 && connack && connack.hasOwnProperty("properties")) { if(node.options.protocolVersion == 5 && connack && connack.hasOwnProperty("properties")) {
let mqttServerV5Properties = arguments[0].properties; if(typeof connack.properties == "object") {
if(mqttServerV5Properties) { //clean & assign all props sent from server.
//node.serverProperties = mqttServerV5Properties; //assign all props, below, square them up. setIntProp(connack.properties, node.serverProperties, "topicAliasMaximum", 1);
setIntProp(mqttServerV5Properties, node.serverProperties, "topicAliasMaximum", 1); setIntProp(connack.properties, node.serverProperties, "receiveMaximum", 0);
setIntProp(mqttServerV5Properties, node.serverProperties, "receiveMaximum", 0); setIntProp(connack.properties, node.serverProperties, "sessionExpiryInterval", 0, 0xFFFFFFFF);
setIntProp(mqttServerV5Properties, node.serverProperties, "sessionExpiryInterval", 0, 0xFFFFFFFF); setIntProp(connack.properties, node.serverProperties, "maximumQoS", 0, 2);
setIntProp(mqttServerV5Properties, node.serverProperties, "maximumQoS", 0, 2); setBoolProp(connack.properties, node.serverProperties, "retainAvailable");
setBoolProp(mqttServerV5Properties, node.serverProperties, "retainAvailable"); setBoolProp(connack.properties, node.serverProperties, "wildcardSubscriptionAvailable");
setBoolProp(mqttServerV5Properties, node.serverProperties, "wildcardSubscriptionAvailable"); setBoolProp(connack.properties, node.serverProperties, "subscriptionIdentifiersAvailable");
setBoolProp(mqttServerV5Properties, node.serverProperties, "subscriptionIdentifiersAvailable"); setBoolProp(connack.properties, node.serverProperties, "sharedSubscriptionAvailable");
setBoolProp(mqttServerV5Properties, node.serverProperties, "sharedSubscriptionAvailable"); setIntProp(connack.properties, node.serverProperties, "maximumPacketSize", 0);
setIntProp(mqttServerV5Properties, node.serverProperties, "maximumPacketSize", 0); setIntProp(connack.properties, node.serverProperties, "serverKeepAlive");
setIntProp(mqttServerV5Properties, node.serverProperties, "serverKeepAlive"); setStrProp(connack.properties, node.serverProperties, "responseInformation");
setStrProp(mqttServerV5Properties, node.serverProperties, "responseInformation"); setStrProp(connack.properties, node.serverProperties, "serverReference");
setStrProp(mqttServerV5Properties, node.serverProperties, "serverReference"); setStrProp(connack.properties, node.serverProperties, "assignedClientIdentifier");
setStrProp(mqttServerV5Properties, node.serverProperties, "assignedClientIdentifier"); setStrProp(connack.properties, node.serverProperties, "reasonString");
setStrProp(mqttServerV5Properties, node.serverProperties, "reasonString"); setUserProperties(connack.properties, node.serverProperties);
setUserProperties(mqttServerV5Properties, node.serverProperties);
debug("MQTTBrokerNode: ⬆ CONNECTED. node.serverProperties ==> ", node.serverProperties ); debug("MQTTBrokerNode: ⬆ CONNECTED. node.serverProperties ==> ", node.serverProperties );
} }
} }