MqttBrowserClient class



MqttBrowserClient(String server, String clientIdentifier, {int maxConnectionAttempts: 3})
Initializes a new instance of the MqttServerClient class using the default Mqtt Port. The server hostname to connect to The client identifier to use to connect with
MqttBrowserClient.withPort(String server, String clientIdentifier, int port, {int maxConnectionAttempts: 3})
Initializes a new instance of the MqttServerClient class using the supplied Mqtt Port. The server hostname to connect to The client identifier to use to connect with The port to use


autoReconnect bool
Auto reconnect, the client will auto reconnect if set true. [...]
read / write, inherited
clientEventBus EventBus
The event bus
@protected, read / write, inherited
clientIdentifier String
Client identifier
read / write, inherited
connectionHandler ↔ dynamic
The Handler that is managing the connection to the remote server.
@protected, read / write, inherited
connectionMessage MqttConnectMessage
The connection message to use to override the default
read / write, inherited
connectionState MqttConnectionState
Gets the current connection state of the Mqtt Client. Will be removed, use connectionStatus
@Deprecated('Use ConnectionStatus, not this'), read-only, inherited
connectionStatus MqttClientConnectionStatus
Gets the current connection status of the Mqtt Client. This is the connection state as above also with the broker return code. Set after every connection attempt.
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
instantiationCorrect bool
Incorrect instantiation protection
@protected, read / write, inherited
keepAlive MqttConnectionKeepAlive
Handles the connection management while idle.
@protected, read / write, inherited
keepAlivePeriod int
Keep alive period, seconds
read / write, inherited
maxConnectionAttempts int
Max connection attempts
onAutoReconnect AutoReconnectCallback
Auto reconnect callback, if auto reconnect is selected this callback will be called before auto reconnect processing is invoked to allow the user to perform any pre auto reconnect actions.
read / write, inherited
onConnected ConnectCallback
Client connect callback, called on successful connect
read / write, inherited
onDisconnected DisconnectCallback
Client disconnect callback, called on unsolicited disconnect. This will not be called even if set if [autoReconnect} is set,instead AutoReconnectCallback will be called.
read / write, inherited
onSubscribed SubscribeCallback
On subscribed
read / write, inherited
onSubscribeFail SubscribeFailCallback
On subscribed fail
read / write, inherited
onUnsubscribed UnsubscribeCallback
On unsubscribed
read / write, inherited
pongCallback PongCallback
The ping received callback
read / write, inherited
port int
Port number
read / write, inherited
published Stream<MqttPublishMessage>
Published message stream. A publish message is added to this stream on completion of the message publishing protocol for a Qos level. Attach listeners only after connect has been called.
read-only, inherited
publishingManager PublishingManager
Handles everything to do with publication management.
@protected, read / write, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
server String
Server name
read / write, inherited
subscriptionsManager SubscriptionsManager
The subscriptions manager responsible for tracking subscriptions.
@protected, read / write, inherited
updates Stream<List<MqttReceivedMessage<MqttMessage>>>
The stream on which all subscribed topic updates are published to
read-only, inherited
websocketProtocols List<String>
User definable websocket protocols. Use this for non default websocket protocols only if your broker needs this. There are two defaults in MqttWsConnection class, the multiple protocol is the default. Some brokers will not accept a list and only expect a single protocol identifier, in this case use the single protocol default. You can supply your own list, or to disable this entirely set the protocols to an empty list , i.e [].
write-only, inherited
websocketProtocolString List<String>
@protected, read / write, inherited


checkCredentials(String username, String password) → void
Check the username and password validity
@protected, inherited
connect([String username, String password]) Future<MqttClientConnectionStatus>
Performs a connect to the message broker with an optional username and password for the purposes of authentication. If a username and password are supplied these will override any previously set in a supplied connection message so if you supply your own connection message and use the authenticateAs method to set these parameters do not set them again here.
disconnect() → void
Disconnect from the broker. This is a hard disconnect, a disconnect message is sent to the broker and the client is then reset to its pre-connection state, i.e all subscriptions are deleted, on subsequent reconnection the use must re-subscribe, also the updates change notifier is re-initialised and as such the user must re-listen on this stream. [...]
doAutoReconnect({bool force: false}) → void
Auto reconnect method, used to invoke a manual auto reconnect sequence. If autoReconnect is not set this method does nothing. If the client is not disconnected this method will have no effect unless the force parameter is set to true, otherwise auto reconnect will try indefinitely to reconnect to the broker.
getConnectMessage(String username, String password) MqttConnectMessage
Gets a pre-configured connect message if one has not been supplied by the user. Returns an MqttConnectMessage that can be used to connect to a message broker.
@protected, inherited
getSubscriptionsStatus(String topic) MqttSubscriptionStatus
Gets the current status of a subscription.
internalDisconnect() → void
Internal disconnect This is always passed to the connection handler to allow the client to close itself down correctly on disconnect.
@protected, inherited
logging({bool on}) → void
Turn on logging, true to start, false to stop
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
publishMessage(String topic, MqttQos qualityOfService, Uint8Buffer data, {bool retain: false}) int
Publishes a message to the message broker. Returns The message identifer assigned to the message. Raises InvalidTopicException if the topic supplied violates the MQTT topic format rules.
setProtocolV31() → void
Set the protocol version to V3.1 - default
setProtocolV311() → void
Set the protocol version to V3.1.1
subscribe(String topic, MqttQos qosLevel) Subscription
Initiates a topic subscription request to the connected broker with a strongly typed data processor callback. The topic to subscribe to. The qos level the message was published at. Returns the subscription or null on failure
toString() String
Returns a string representation of this object.
unsubscribe(String topic) → void
Unsubscribe from a topic


operator ==(dynamic other) bool
The equality operator. [...]