OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 /// MQTT client library for the [MQTT protocol](http://mqtt.org/), a lightweight | 5 /// MQTT client library for the [MQTT protocol](http://mqtt.org/), a lightweight |
6 /// IoT pub/sub messaging protocol. | 6 /// IoT pub/sub messaging protocol. |
7 /// | 7 /// |
8 /// The implementation uses the [Paho C client | 8 /// The implementation uses the [Paho C client |
9 /// library](http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.c.git/about/). | 9 /// library](http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.c.git/about/). |
10 /// | 10 /// |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 /// ``` | 48 /// ``` |
49 /// | 49 /// |
50 /// See ```/pkg/mqtt/publish-sample.dart/``` for additional details. | 50 /// See ```/pkg/mqtt/publish-sample.dart/``` for additional details. |
51 /// | 51 /// |
52 /// Dependencies | 52 /// Dependencies |
53 /// ------------ | 53 /// ------------ |
54 /// | 54 /// |
55 /// This Dart library depends on the [Paho C | 55 /// This Dart library depends on the [Paho C |
56 /// library](http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.c.git/about/). | 56 /// library](http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.c.git/about/). |
57 /// It will load the Paho shared object file (.so file) dynamically at runtime. | 57 /// It will load the Paho shared object file (.so file) dynamically at runtime. |
58 /// Therefore the Paho shared object file needs to be copied into the Fletch | 58 /// Therefore the Paho shared object file needs to be copied into the Dartino |
59 /// SDK. Follow these instructions to compile and copy the library: | 59 /// SDK. Follow these instructions to compile and copy the library: |
60 /// | 60 /// |
61 /// 1. Get the Paho source code | 61 /// 1. Get the Paho source code |
62 /// ``` | 62 /// ``` |
63 /// $ git clone https://git.eclipse.org/r/paho/org.eclipse.paho.mqtt.c | 63 /// $ git clone https://git.eclipse.org/r/paho/org.eclipse.paho.mqtt.c |
64 /// ``` | 64 /// ``` |
65 /// | 65 /// |
66 /// 1. Compile the source code | 66 /// 1. Compile the source code |
67 /// ``` | 67 /// ``` |
68 /// $ cd org.eclipse.paho.mqtt.c/ | 68 /// $ cd org.eclipse.paho.mqtt.c/ |
69 /// $ make | 69 /// $ make |
70 /// ``` | 70 /// ``` |
71 /// | 71 /// |
72 /// 1. Copy the library to the lib directory Fletch SDK (substitute `<Fletch SDK | 72 /// 1. Copy the library to the lib directory Dartino SDK (substitute `<Dartino S
DK |
73 /// location>` with the location where you installed the Fletch SDK, e.g. | 73 /// location>` with the location where you installed the Dartino SDK, e.g. |
74 /// ~/fletch-sdk/) | 74 /// ~/dartino-sdk/) |
75 /// | 75 /// |
76 /// ``` | 76 /// ``` |
77 /// $ cd org.eclipse.paho.mqtt.c/ | 77 /// $ cd org.eclipse.paho.mqtt.c/ |
78 /// $ cp build/output/libpaho-mqtt3c.so <Fletch SDK location>/lib/ | 78 /// $ cp build/output/libpaho-mqtt3c.so <Dartino SDK location>/lib/ |
79 /// | 79 /// |
80 /// ``` | 80 /// ``` |
81 /// | 81 /// |
82 /// Reporting issues | 82 /// Reporting issues |
83 /// ---------------- | 83 /// ---------------- |
84 /// | 84 /// |
85 /// Please file an issue [in the issue tracker](https://github.com/dartino/sdk/i
ssues/new?title=Add%20title&labels=Area-Package&body=%3Cissue%20description%3E%0
A%3Crepro%20steps%3E%0A%3Cexpected%20outcome%3E%0A%3Cactual%20outcome%3E). | 85 /// Please file an issue [in the issue tracker](https://github.com/dartino/sdk/i
ssues/new?title=Add%20title&labels=Area-Package&body=%3Cissue%20description%3E%0
A%3Crepro%20steps%3E%0A%3Cexpected%20outcome%3E%0A%3Cactual%20outcome%3E). |
86 | 86 |
87 library mqtt; | 87 library mqtt; |
88 | 88 |
89 import 'dart:fletch'; | 89 import 'dart:dartino'; |
90 import 'package:os/os.dart'; | 90 import 'package:os/os.dart'; |
91 import 'package:immutable/immutable.dart'; | 91 import 'package:immutable/immutable.dart'; |
92 | 92 |
93 import 'src/mqtt_client.dart'; | 93 import 'src/mqtt_client.dart'; |
94 | 94 |
95 /// Attempt to connect with MQTT 3.1.1, and if that fails, falls back to 3.1. | 95 /// Attempt to connect with MQTT 3.1.1, and if that fails, falls back to 3.1. |
96 const int protocolVersionNegotiate = 0; | 96 const int protocolVersionNegotiate = 0; |
97 /// Connect only using MQTT 3.1 | 97 /// Connect only using MQTT 3.1 |
98 const int protocolVersionOnly_3_1 = 3; | 98 const int protocolVersionOnly_3_1 = 3; |
99 /// Connect only using MQTT 3.1.1 | 99 /// Connect only using MQTT 3.1.1 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 var handler = subscriptions[msg.topic]; | 227 var handler = subscriptions[msg.topic]; |
228 if (handler != null) { | 228 if (handler != null) { |
229 // Call the event handler for topic. | 229 // Call the event handler for topic. |
230 handler(msg.message, msg.topic); | 230 handler(msg.message, msg.topic); |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
234 } | 234 } |
235 } | 235 } |
236 } | 236 } |
OLD | NEW |