MqttBrowserClient class

Inheritance

Constructors

MqttBrowserClient(String server, String clientIdentifier, {int maxConnectionAttempts = MqttConstants.defaultMaxConnectionAttempts})
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 = MqttConstants.defaultMaxConnectionAttempts})
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

Properties

authentication Stream<MqttAuthenticateMessage>?
Authenticate message stream. A received authenticate message is added to this stream. Attach listeners only after connect has been called.
no setterinherited
authenticationManager MqttAuthenticationManager?
Handles everything to do with authentication messages.
getter/setter pairinherited
autoReconnect bool
Auto reconnect, the client will auto reconnect if set true.
getter/setter pairinherited
clientEventBus ↔ EventBus?
The event bus
getter/setter pairinherited
clientIdentifier String
Client identifier
getter/setter pairinherited
connectionHandler ↔ dynamic
The Handler that is managing the connection to the remote server.
getter/setter pairinherited
connectionMessage MqttConnectMessage?
The connection message to use to override the default
getter/setter pairinherited
connectionState MqttConnectionState?
Gets the current connection state of the Mqtt Client. Will be removed, use connectionStatus
no setterinherited
connectionStatus MqttConnectionStatus?
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.
no setterinherited
disconnectOnNoResponsePeriod int
The period of time to wait if the broker does not respond to a ping request from keep alive processing, in seconds. If this time period is exceeded the client is forcibly disconnected. The default is 0, which disables this functionality. Thi setting has no effect if keep alive is disabled.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
instantiationCorrect bool
Incorrect instantiation protection
getter/setter pairinherited
keepAlive MqttConnectionKeepAlive?
Handles the connection management while idle.
getter/setter pairinherited
keepAlivePeriod int
Keep alive period, seconds. The default is 0 which disables the keep alive mechanism. To enable the keep alive mechanism set this to a value greater than 0.
getter/setter pairinherited
maxConnectionAttempts int
Max connection attempts
final
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.
getter/setter pairinherited
onAutoReconnected AutoReconnectCompleteCallback?
Auto reconnected callback, if auto reconnect is selected this callback will be called after auto reconnect processing is completed to allow the user to perform any post auto reconnect actions.
getter/setter pairinherited
onConnected ConnectCallback?
Client connect callback, called on successful connect
getter/setter pairinherited
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.
getter/setter pairinherited
onFailedConnectionAttempt FailedConnectionAttemptCallback?
Failed Connection attempt callback. Called on every failed connection attempt, if maxConnectionAttempts is set to 5 say this will be called 5 times if the connection fails, one for every failed attempt. Note this is never called if autoReconnect is set. If autoReconnect is set, the MqttNoConnectionException is not raised if this callback is supplied.
getter/setter pairinherited
onSubscribed SubscribeCallback?
On subscribed
getter/setter pairinherited
onSubscribeFail SubscribeFailCallback?
On subscribed fail
getter/setter pairinherited
onUnsubscribed UnsubscribeCallback?
On unsubscribed
getter/setter pairinherited
pongCallback PongCallback?
The ping received callback
getter/setter pairinherited
port int?
Port number
getter/setter pairinherited
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.
no setterinherited
publishingManager MqttPublishingManager?
Handles everything to do with publication management.
getter/setter pairinherited
resubscribeOnAutoReconnect bool
Re subscribe on auto reconnect. Auto reconnect will perform automatic re subscription of existing confirmed subscriptions unless this is set to false. In this case the caller must perform their own re subscriptions manually using unsubscribe, subscribe and resubscribe as needed from the appropriate callbacks.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
server String
Server name
getter/setter pairinherited
subscriptionsManager MqttSubscriptionManager?
The subscriptions manager responsible for tracking subscriptions.
getter/setter pairinherited
updates Stream<List<MqttReceivedMessage<MqttMessage>>>
The stream on which all subscribed topic updates are published to
no setterinherited
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 single 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 [].
no getterinherited
websocketProtocolString List<String>?
getter/setter pairinherited

Methods

checkCredentials(String? username, String? password) → void
Check the username and password validity
inherited
connect([String? username, String? password]) Future<MqttConnectionStatus?>
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.
override
disconnect() → void
Disconnect from the broker.
inherited
disconnectOnNoPingResponse(DisconnectOnNoPingResponse event) → void
Called when the keep alive mechanism has determined that a ping response expected from the broker has not arrived in the time period specified by disconnectOnNoResponsePeriod.
inherited
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.
inherited
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 if the user has not set one.
inherited
getSubscriptionStatus(MqttSubscription subscription) MqttSubscriptionStatus
Gets the current status of a subscription.
inherited
getSubscriptionTopicStatus(String topic) MqttSubscriptionStatus
Gets the current status of a subscription topic.
inherited
internalDisconnect() → void
Internal disconnect.
inherited
logging({required bool on}) → void
Turn on logging, true to start, false to stop
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publishMessage(String topic, MqttQos qualityOfService, Uint8Buffer data, {bool retain = false, List<MqttUserProperty>? userProperties}) 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.
inherited
publishUserMessage(MqttPublishMessage message) int
Publishes a user supplied publish message to the message broker. This allows the user to custom build the publish message as is needed. The user is responsible for the integrity of the publishing message. Returns the message identifier assigned to the message. Note that any supplied message identifier will be overridden by this method.
inherited
reauthenticate(MqttAuthenticateMessage msg, {int waitTimeInSeconds = 30}) Future<MqttAuthenticateMessage>
Re-authenticate.
inherited
resubscribe() → void
Re subscribe. Unsubscribes all confirmed subscriptions and re subscribes them without sending unsubscribe messages to the broker. If an unsubscribe message to the broker is needed then use unsubscribe followed by subscribe for each subscription. Can be used in auto reconnect processing to force manual re subscription of all existing confirmed subscriptions.
inherited
sendAuthenticate(MqttAuthenticateMessage message) → void
Send an authenticate message to the broker.
inherited
subscribe(String topic, MqttQos qosLevel) MqttSubscription?
Initiates a topic subscription request to the connected broker with a strongly typed data processor callback. The topic to subscribe to. The maximum Qos level. Returns the subscription or null on failure
inherited
subscribeWithSubscription(MqttSubscription subscription) MqttSubscription?
Initiates a topic subscription request to the connected broker with a strongly typed data processor callback. The subscription to subscribe to. Returns the subscription or null on failure
inherited
subscribeWithSubscriptionList(List<MqttSubscription> subscriptions) List<MqttSubscription>?
Initiates a topic subscription request to the connected broker with a strongly typed data processor callback. The list of subscriptions to subscribe to. Note that user properties are set on a per message basis not a per subscription basis, if you wish to send user properties then set them on the first subscription in the list. Returns the subscriptions or null on failure
inherited
toString() String
A string representation of this object.
inherited
unsubscribeStringTopic(String topic) → void
Unsubscribe from a topic.
inherited
unsubscribeSubscription(MqttSubscription subscription) → void
Unsubscribe from a subscription.
inherited
unsubscribeSubscriptionList(List<MqttSubscription> subscriptions) → void
Unsubscribe from a subscription list. Note that user properties are set on a per message basis not a per subscription basis, if you wish to send user properties then set them on the first subscription in the list.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited