MqttConnection class Null safety
Connection to MQTT message broker.
MQTT is a popular light-weight protocol to communicate IoT devices.
Configuration parameters
client_id
: (optional) name of the client idconnection(s)
:discovery_key
: (optional) a key to retrieve the connection from IDiscoveryhost
: host name or IP addressport
: port numberuri
: resource URI or connection string with all parameters in it
credential(s)
:store_key
: (optional) a key to retrieve the credentials from ICredentialStoreusername
: user namepassword
: user password
options
:retry_connect
: (optional) turns on/off automated reconnect when connection is log (default: true)connect_timeout
: (optional) number of milliseconds to wait for connection (default: 30000)reconnect_timeout
: (optional) number of milliseconds to wait on each reconnection attempt (default: 1000)keepalive_timeout
: (optional) number of milliseconds to ping broker while inactive (default: 3000)
References
- :logger::*:1.0 (optional) ILogger components to pass log messages
- :counters::*:1.0 (optional) ICounters components to pass collected measurements
- :discovery::*:1.0 (optional) IDiscovery services to resolve connections
- :credential-store::*:1.0 (optional) Credential stores to resolve credentials
See MessageQueue See MessagingCapabilities
- Implemented types
Constructors
Properties
- clientId_ ↔ String
-
read / write
- connection_ ↔ MqttServerClient?
-
The NATS connection pool object.
read / write
- connectionResolver_ ↔ MqttConnectionResolver
-
The connection resolver.
read / write
- connectTimeout_ ↔ int
-
read / write
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- keepAliveTimeout_ ↔ int
-
read / write
- logger_ ↔ CompositeLogger
-
The logger.
read / write
- options_ ↔ ConfigParams
-
The configuration options.
read / write
- reconnectTimeout_ ↔ int
-
read / write
- retryConnect_ ↔ bool
-
read / write
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
-
subscriptions_
↔ List<
MqttSubscription> -
Topic subscriptions
read / write
Methods
-
checkOpen(
) → void - Checks if connection is open
-
close(
String? correlationId) → Future -
Closes component and frees used resources.
override
-
configure(
ConfigParams config) → void -
Configures component by passing configuration parameters.
override
-
createQueue(
String name) → Future< void> -
Creates a message queue.
If connection doesn't support this function it exists without error.
override
-
deleteQueue(
String name) → Future< void> -
Deletes a message queue.
If connection doesn't support this function it exists without error.
override
-
getConnection(
) → MqttServerClient? -
isOpen(
) → bool -
Checks if the component is opened.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
open(
String? correlationId) → Future -
Opens the component.
override
-
publish(
String topic, String data, Map< String, dynamic> options) → Future - Publish a message to a specified topic
-
readQueueNames(
) → Future< List< String> > -
Reads a list of registered queue names.
If connection doesn't support this function returnes an empty list.
override
-
setReferences(
IReferences references) → void -
Sets references to dependent components.
override
-
subscribe(
String topic, Map< String, dynamic> options, IMqttMessageListener listener) → Future -
toString(
) → String -
A string representation of this object.
inherited
-
unsubscribe(
String topic, IMqttMessageListener listener) → Future
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited