mqtt 1.1.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 82

Mqtt

This is an mqtt client written in DART. It can be used in the browser (over websocket) or the VM (over socker or websocket).

See http://mqtt.org/ for details on mqtt protocol

Usage

Create a connection over websocket: var mqttCnx = new MqttConnectionIOWebSocket.setOptions("ws://127.0.0.1/8080");

Create a connection over socket: var mqttCnx = new MqttConnectionIOSocket.setOptions(host:127.0.0.1, port: 8083);

Create mqtt client: MqttClient c = new MqttClient(mqttCnx, clientID: "MyClientID", qos: QOS_1);

Set a will (must be done before connecting to the broker): c.setWill("MyWillTopic", "MyWillPayload", QOS_1, 0);

Connect to broker: c.connect(onConnectionLost) .then( (c)=> onConnected(c) ) .catchError((e) => print("Error: $e"), test: (e) => e is SocketException)
.catchError((mqttErr) => print("Error: $mqttErr") );

Publish a message: c.publish("MyTopic", "MyMessage", 1, QOS_1, 0) .then( (m) => print("Message ${m.messageID} published"); );

Subscribe to a topic: c.subscribe("MyTopic", QOS_1, onMessage) .then( (s) => print("Subscription done - ID: ${s.messageID} - Qos: ${s.grantedQoS}") );

Unsubscribe: c.unsubscribe("MyTopic", s.messageID) .then( (u) => print("Unsubscribed from subscription ${u.messageID}") );

Disconnect: c.disconnect();

VM Example

See mqtt_sub for a sample mqtt publish and mqtt_pub for a sample subscribe. Available options can be displayed through: > dart mqtt_sub.dart -h > dart mqtt_pub.dart -h

Web Example

See Mqtt_web for a sample web page connecting, subscribing and publishing mqtt messages

Testing

Testing was done using the mosquitto broker (http://mosquitto.org/). A mosquitto test server is available at http://test.mosquitto.org/.

Websocket testing was done throught mqtt_ws_bridge.dart.

1.1.2

  • Dart 2 support

1.0.1

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mqtt: "^1.1.2"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:mqtt/mqtt_client.dart';

      import 'package:mqtt/mqtt_connection_html_websocket.dart';

      import 'package:mqtt/mqtt_connection_io_socket.dart';

      import 'package:mqtt/mqtt_connection_io_websocket.dart';

      import 'package:mqtt/mqtt_connection_shared.dart';

      import 'package:mqtt/mqtt_message.dart';

      import 'package:mqtt/mqtt_message_assured.dart';

      import 'package:mqtt/mqtt_message_connack.dart';

      import 'package:mqtt/mqtt_message_connect.dart';

      import 'package:mqtt/mqtt_message_disconnect.dart';

      import 'package:mqtt/mqtt_message_ping.dart';

      import 'package:mqtt/mqtt_message_publish.dart';

      import 'package:mqtt/mqtt_message_suback.dart';

      import 'package:mqtt/mqtt_message_subscribe.dart';

      import 'package:mqtt/mqtt_message_unsuback.dart';

      import 'package:mqtt/mqtt_message_unsubscribe.dart';

      import 'package:mqtt/mqtt_options.dart';

      import 'package:mqtt/mqtt_shared.dart';

      import 'package:mqtt/mqtt_utils.dart';

      import 'package:mqtt/mqtt_version_v3.dart';
  
Version Uploaded Documentation Archive
1.1.2 Jun 4, 2018 Go to the documentation of mqtt 1.1.2 Download mqtt 1.1.2 archive
1.1.0 Oct 24, 2014 Go to the documentation of mqtt 1.1.0 Download mqtt 1.1.0 archive
1.0.2 Jun 4, 2018 Go to the documentation of mqtt 1.0.2 Download mqtt 1.0.2 archive
1.0.0 Jul 12, 2013 Go to the documentation of mqtt 1.0.0 Download mqtt 1.0.0 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
72 / 100
Health:
Code health derived from static analysis. [more]
88 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
97 / 100
Overall score:
Weighted score of the above. [more]
82
Learn more about scoring.

Platforms

Detected platforms: web

Platform components identified in package: html, io.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 5 errors 27 hints.

    Strong-mode analysis of lib/mqtt_message.dart failed with the following error:

    line: 65 col: 3
    Invalid override. The type of 'MqttMessage.==' ('(MqttMessage) → bool') isn't a subtype of 'Object.==' ('(dynamic) → bool').

    Strong-mode analysis of lib/mqtt_message_publish.dart failed with the following error:

    line: 31 col: 3
    Invalid override. The type of 'MqttMessagePublish.==' ('(MqttMessagePublish) → bool') isn't a subtype of 'MqttMessage.==' ('(MqttMessage) → bool').

    Similar analysis of the following files failed:

    • lib/mqtt_options.dart (error)
    • lib/mqtt_client.dart (hint)
    • lib/mqtt_connection_html_websocket.dart (hint)
    • lib/mqtt_connection_io_socket.dart (hint)
    • lib/mqtt_connection_io_websocket.dart (hint)
    • lib/mqtt_connection_shared.dart (hint)
    • lib/mqtt_message_assured.dart (hint)
    • lib/mqtt_message_connack.dart (hint)
    • lib/mqtt_message_connect.dart (hint)
    • lib/mqtt_message_disconnect.dart (hint)
    • lib/mqtt_message_ping.dart (hint)
    • lib/mqtt_message_suback.dart (hint)
    • lib/mqtt_message_subscribe.dart (hint)
    • lib/mqtt_message_unsuback.dart (hint)
    • lib/mqtt_message_unsubscribe.dart (hint)
    • lib/mqtt_shared.dart (hint)
    • lib/mqtt_utils.dart (hint)
    • lib/mqtt_version_v3.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use mqtt.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
args ^1.4.3 1.4.3
ini >=1.0.0 <=1.1.0 1.1.0
test ^0.12.0 0.12.42 1.0.0
Transitive dependencies
analyzer 0.32.1
async 2.0.7
boolean_selector 1.0.3
charcode 1.1.1
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
front_end 0.1.1
glob 1.1.5
html 0.13.3+1
http 0.11.3+16
http_multi_server 2.0.5
http_parser 3.1.2
io 0.3.2+1
js 0.6.1
json_rpc_2 2.0.8
kernel 0.3.1
logging 0.11.3+1
matcher 0.12.3
meta 1.1.5
mime 0.9.6+1
multi_server_socket 1.0.1
node_preamble 1.4.2
package_config 1.0.3
package_resolver 1.0.3
path 1.6.1
plugin 0.2.0+2
pool 1.3.5
pub_semver 1.4.1
shelf 0.7.3+1
shelf_packages_handler 1.0.3
shelf_static 0.2.7+1
shelf_web_socket 0.2.2+2
source_map_stack_trace 1.1.4
source_maps 0.10.5
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
string_scanner 1.0.2
term_glyph 1.0.0
typed_data 1.1.5
utf 0.9.0+4
vm_service_client 0.2.4+3
watcher 0.9.7+8
web_socket_channel 1.0.8
yaml 2.1.14