QMqttServerConnectionProperties Class

The QMqttServerConnectionProperties class represents configuration options of a server a QMqttClient is connected to. More...

Header: #include <QMqttServerConnectionProperties>
CMake: find_package(Qt6 REQUIRED COMPONENTS Mqtt)
target_link_libraries(mytarget PRIVATE Qt6::Mqtt)
qmake: QT += mqtt
Inherits: QMqttConnectionProperties

Public Types

enum ServerPropertyDetail { None, SessionExpiryInterval, MaximumReceive, MaximumQoS, RetainAvailable, …, AuthenticationData }
flags ServerPropertyDetails

Public Functions

QMqttServerConnectionProperties::ServerPropertyDetails availableProperties() const
bool clientIdAssigned() const
bool isValid() const
quint8 maximumQoS() const
QString reason() const
QMqtt::ReasonCode reasonCode() const
QString responseInformation() const
bool retainAvailable() const
quint16 serverKeepAlive() const
QString serverReference() const
bool sharedSubscriptionSupported() const
bool subscriptionIdentifierSupported() const
bool wildcardSupported() const

Detailed Description

When a connection has been established the server might send additional details about the connection properties. Use availableProperties() to identify properties set by the server. If a property is not set by the server, default values are assumed and can be obtained by invoking access functions of this instance.

Note: Connection properties are part of the MQTT 5.0 specification and cannot be used when connecting with a lower protocol level. See QMqttClient::ProtocolVersion for more information.

Member Type Documentation

enum QMqttServerConnectionProperties::ServerPropertyDetail
flags QMqttServerConnectionProperties::ServerPropertyDetails

This enum type specifies the available properties set by the server or the client after establishing a connection.

ConstantValueDescription
QMqttServerConnectionProperties::None0x00000000No property has been specified.
QMqttServerConnectionProperties::SessionExpiryInterval0x00000001The number of seconds the server keeps the session after a disconnect.
QMqttServerConnectionProperties::MaximumReceive0x00000002The maximum number of QoS 1 and 2 message the server is capable of managing concurrently.
QMqttServerConnectionProperties::MaximumQoS0x00000004The maximum QoS level the server can understand.
QMqttServerConnectionProperties::RetainAvailable0x00000010Specifies whether retained messages are supported.
QMqttServerConnectionProperties::MaximumPacketSize0x00000020Specifies the maximum packet size including the message header and properties.
QMqttServerConnectionProperties::AssignedClientId0x00000040Specifies whether the server assigned a client identifier.
QMqttServerConnectionProperties::MaximumTopicAlias0x00000080Specifies the maximum amount of topic aliases.
QMqttServerConnectionProperties::ReasonString0x00000100Specifies a string providing more details on connection state.
QMqttServerConnectionProperties::UserProperty0x00000200Specifies additional user properties.
QMqttServerConnectionProperties::WildCardSupported0x00000400Specifies whether the server supports wildcard subscriptions.
QMqttServerConnectionProperties::SubscriptionIdentifierSupport0x00000800Specifies whether the server supports subscription identifiers.
QMqttServerConnectionProperties::SharedSubscriptionSupport0x00001000Specifies whether the server supports shared subscriptions.
QMqttServerConnectionProperties::ServerKeepAlive0x00002000Specifies the number of seconds the server expects a keep alive packet from the client.
QMqttServerConnectionProperties::ResponseInformation0x00004000Specifies the response information.
QMqttServerConnectionProperties::ServerReference0x00008000Specifies an alternative server address for the client to connect to.
QMqttServerConnectionProperties::AuthenticationMethod0x00010000Specifies the authentication method.
QMqttServerConnectionProperties::AuthenticationData0x00020000Specifies the authentication data.

The ServerPropertyDetails type is a typedef for QFlags<ServerPropertyDetail>. It stores an OR combination of ServerPropertyDetail values.

Member Function Documentation

QMqttServerConnectionProperties::ServerPropertyDetails QMqttServerConnectionProperties::availableProperties() const

Returns the available properties specified by the server.

bool QMqttServerConnectionProperties::clientIdAssigned() const

Returns true if the server assigned a new client identifier to the client.

See also QMqttClient::clientId().

bool QMqttServerConnectionProperties::isValid() const

Returns true if the server provided properties as part of the connection aknowledgment. Returns false if no properties have been provided.

quint8 QMqttServerConnectionProperties::maximumQoS() const

Returns the maximum QoS level the server supports for publishing messages. Publishing messages with QoS level exceeding the maximum QoS level reported by the server is a protocol violation.

If the client does not need to support QoS 1 or QoS 2, it should restrict the maximum QoS level in any subscription it does to a value it can support; the server would then publish messages with the maximum of supported and restricted QoS levels.

The default value is 2.

See also QMqttClient::publish() and QMqttClient::subscribe().

QString QMqttServerConnectionProperties::reason() const

Returns the reason string associated with this response.

QMqtt::ReasonCode QMqttServerConnectionProperties::reasonCode() const

Returns the reason code associated with this response.

QString QMqttServerConnectionProperties::responseInformation() const

Returns the response information.

bool QMqttServerConnectionProperties::retainAvailable() const

Returns true if the server accepts retained messages. The default value is true.

quint16 QMqttServerConnectionProperties::serverKeepAlive() const

Returns the number of seconds the server requested as keep alive. This overwrites the keep alive being set from the client side.

See also QMqttClient::setKeepAlive().

QString QMqttServerConnectionProperties::serverReference() const

Returns a server address which can be used by the client alternatively to connect to. Typically, this is used together with the reason code 0x9c (Use another server) or 0x9c (Server moved).

bool QMqttServerConnectionProperties::sharedSubscriptionSupported() const

Returns true if the server accepts shared subscriptions. The default value is true.

bool QMqttServerConnectionProperties::subscriptionIdentifierSupported() const

Returns true if the server accepts subscription identifiers. Subscription identifiers can be passed to the server when creating a new subscription.

The default value is true.

See also QMqttSubscriptionProperties::setSubscriptionIdentifier().

bool QMqttServerConnectionProperties::wildcardSupported() const

Returns true if the server accepts subscriptions including wildcards. The default value is true.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.