Skip to content

Commit 939208e

Browse files
committed
Merge branch 'release/0.0.4-beta'
2 parents 1f08b98 + b18535c commit 939208e

15 files changed

+2032
-2193
lines changed

.jscsrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"preset": "google",
3+
"disallowSpacesInAnonymousFunctionExpression": null,
4+
"excludeFiles": ["node_modules/**"]
5+
}

.jshintrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"node": true,
3+
"browser": true,
4+
"bitwise": true,
5+
"camelcase": true,
6+
"curly": true,
7+
"eqeqeq": true,
8+
"immed": true,
9+
"indent": 2,
10+
"latedef": true,
11+
"noarg": true,
12+
"quotmark": "single",
13+
"undef": true,
14+
"unused": true,
15+
"newcap": false,
16+
"globals": {
17+
"wrap": true,
18+
"unwrap": true,
19+
"Polymer": true,
20+
"Platform": true,
21+
"page": true,
22+
"app": true
23+
}
24+
}

README.md

Lines changed: 100 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![mqtt-elements](https://raw.githubusercontent.com/mqttjs/mqtt-elements/67266290fe6a0b6b3ff51418efb7c1c0662c78c5/assets/mqtt-elements.png)
22
=======
33

4-
Polymer elements to establish a MQTT connection to an MQTT broker.
4+
Polymer elements to establish a MQTT connection to a MQTT broker.
55

66
## API
77

@@ -10,7 +10,7 @@ Polymer elements to establish a MQTT connection to an MQTT broker.
1010
## Install
1111

1212
```
13-
bower install --save mqttjs/mqtt-elements
13+
bower install --save mqtt-elements
1414
```
1515

1616
## Import
@@ -22,7 +22,7 @@ bower install --save mqttjs/mqtt-elements
2222
## Usage
2323

2424
```
25-
<mqtt-connection auto url="ws://127.0.0.1:3005">
25+
<mqtt-connection auto url="ws://HOST:PORT">
2626
<mqtt-subscription
2727
topic="foo/bar"
2828
number-of-messages="Infinity"
@@ -38,6 +38,101 @@ bower install --save mqttjs/mqtt-elements
3838
</mqtt-connection>
3939
```
4040

41+
### Connect
42+
43+
```
44+
<mqtt-connection url="ws://HOST:PORT"></mqtt-connection>
45+
```
46+
47+
The method `<mqtt-connection>#connect` has to be called manually to establish the MQTT connection to the MQTT broker.
48+
Set `<mqtt-connection>#auto` flag to make the MQTT connection as soon as possible.
49+
50+
51+
### Connect with Username / Password
52+
53+
```
54+
<mqtt-connection
55+
url="ws://HOST:PORT"
56+
options='{"username": "USERNAME", "password": "PASSWORD"}'
57+
with-credentials
58+
auto>
59+
</mqtt-connection>
60+
```
61+
62+
OR
63+
64+
```
65+
<mqtt-connection
66+
url="ws://HOST:PORT"
67+
username="USERNAME"
68+
password="PASSWORD"
69+
with-credentials
70+
auto>
71+
</mqtt-connection>
72+
```
73+
74+
The flag `<mqtt-connection>#withCredentials` indecates the MQTT connection to wait until a username and password for
75+
the connection is supplied.
76+
77+
### Publish
78+
79+
The following example will publish on the topic »mqtt/elements« with the payload »Publishing via a HTML element«.
80+
Every time when `<mqtt-publish>#payload` changes the element will publish a new MQTT message to the topic »mqtt/elements«.
81+
If the `<mqtt-publish>#auto` flag is not set - `<mqtt-publish>#publish` has to be called to publish a MQTT message to the topic
82+
83+
```
84+
<mqtt-connection
85+
url="ws://HOST:PORT"
86+
auto>
87+
<mqtt-publish topic="mqtt/elements" payload="Publishing via a HTML element" auto></mqtt-publish>
88+
</mqtt-connection>
89+
```
90+
91+
#### Publish on multiple topic
92+
93+
A `<mqtt-connection>` element can hold any number of `<mqtt-publish>` elements to publish to different topics.
94+
95+
```
96+
<mqtt-connection
97+
url="ws://HOST:PORT"
98+
auto>
99+
<mqtt-publish topic="foo/bar" payload="this is easy" auto></mqtt-publish>
100+
<mqtt-publish topic="client/status" payload="online" qos="1" auto></mqtt-publish>
101+
<mqtt-publish topic="client/location" payload="{'foo': 'bar'}" auto></mqtt-publish>
102+
</mqtt-connection>
103+
```
104+
105+
#### Publish a retained message
106+
107+
To publish a message with the RETAINED flag set to true add the `<mqtt-publish>#retained` flag.
108+
109+
```
110+
<mqtt-connection
111+
url="ws://HOST:PORT"
112+
auto>
113+
<mqtt-publish topic="foo/bar" payload="this is easy" retained auto></mqtt-publish>
114+
</mqtt-connection>
115+
```
116+
117+
### Subscribe
118+
119+
```
120+
<mqtt-connection
121+
url="ws://HOST:PORT"
122+
auto>
123+
<mqtt-subscription topic="foo/bar"></mqtt-subscription>
124+
</mqtt-connection>
125+
```
126+
127+
The last message to the topic will be save in `<mqtt-subscription>#lastMessage`. The `<mqtt-subscription>` stores the
128+
last `n` messages within the `<mqtt-subscription>#messages` array. Set `<mqtt-subscription>#numberOfMessages` to the
129+
number of messages that should be saved in `<mqtt-subscription>#messages`. To save every message received on the topic
130+
set `<mqtt-subscription>#numberOfMessages` to `Infinity`.
131+
132+
## Media
133+
134+
* [MQTT Client Library Encyclopedia](http://www.hivemq.com/blog/mqtt-client-library-encyclopedia-mqttelements?utm_medium=social&utm_source=github-mqttjs)
135+
41136
## Development
42137

43138
```
@@ -51,15 +146,10 @@ grunt serve
51146
```
52147

53148

54-
#### Update annd bundel MQTT.js
149+
#### Bundel MQTT.js, MQEmitter and Store
55150

56151
```
57-
browserify node_modules/mqtt/mqtt.js -o dist/mqtt.js
152+
browserify -r ./node_modules/mqtt/lib/store.js:Store -r mqtt -r MQEmitter > dist/mqtt-elements-bundle.js
58153
59154
```
60155

61-
#### Update and bundel mqemitter
62-
```
63-
browserify node_modules/mqemitter/mqemitter.js --standalone MQEmitter -o dist/mqemitter.js
64-
65-
```

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mqtt-elements",
3-
"version": "0.0.3-beta",
3+
"version": "0.0.4-beta",
44
"homepage": "https://github.com/mqttjs/mqtt-elements",
55
"description": "Polymer elements for MQTT",
66
"main": "mqtt-elements.html",

0 commit comments

Comments
 (0)