Skip to content

Commit

Permalink
updates snazzy
Browse files Browse the repository at this point in the history
  • Loading branch information
YoDaMa committed Oct 19, 2021
1 parent 8f8abc7 commit 2b5e31f
Show file tree
Hide file tree
Showing 18 changed files with 1,920 additions and 1,926 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ npm install mqtt --save
For the sake of simplicity, let's put the subscriber and the publisher in the same file:

```js
var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://test.mosquitto.org')
const mqtt = require('mqtt')
const client = mqtt.connect('mqtt://test.mosquitto.org')

client.on('connect', function () {
client.subscribe('presence', function (err) {
Expand Down Expand Up @@ -659,8 +659,8 @@ Support [WeChat Mini Program](https://mp.weixin.qq.com/). See [Doc](https://mp.w
## Example(js)

```js
var mqtt = require('mqtt')
var client = mqtt.connect('wxs://test.mosquitto.org')
const mqtt = require('mqtt')
const client = mqtt.connect('wxs://test.mosquitto.org')
```

## Example(ts)
Expand All @@ -677,8 +677,8 @@ Surport [Ali Mini Program](https://open.alipay.com/channel/miniIndex.htm). See [
## Example(js)

```js
var mqtt = require('mqtt')
var client = mqtt.connect('alis://test.mosquitto.org')
const mqtt = require('mqtt')
const client = mqtt.connect('alis://test.mosquitto.org')
```

## Example(ts)
Expand Down Expand Up @@ -711,7 +711,7 @@ gzip <browserMqtt.js | wc -c
<a name="webpack"></a>
### Webpack

Just like browserify, export MQTT.js as library. The exported module would be `var mqtt = xxx` and it will add an object in the global space. You could also export module in other [formats (AMD/CommonJS/others)](http://webpack.github.io/docs/configuration.html#output-librarytarget) by setting **output.libraryTarget** in webpack configuration.
Just like browserify, export MQTT.js as library. The exported module would be `const mqtt = xxx` and it will add an object in the global space. You could also export module in other [formats (AMD/CommonJS/others)](http://webpack.github.io/docs/configuration.html#output-librarytarget) by setting **output.libraryTarget** in webpack configuration.

```javascript
npm install -g webpack // install webpack
Expand All @@ -731,7 +731,7 @@ you can then use mqtt.js in the browser with the same api than node's one.
<body>
<script src="./browserMqtt.js"></script>
<script>
var client = mqtt.connect() // you add a ws:// url here
const client = mqtt.connect() // you add a ws:// url here
client.subscribe("mqtt/demo")
client.on("message", function (topic, payload) {
Expand Down
2 changes: 1 addition & 1 deletion examples/client/simple-both.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const mqtt = require('../..')
const client = mqtt.connect()

// or var client = mqtt.connect({ port: 1883, host: '192.168.1.100', keepalive: 10000});
// or const client = mqtt.connect({ port: 1883, host: '192.168.1.100', keepalive: 10000});

client.subscribe('presence')
client.publish('presence', 'bin hier')
Expand Down
14 changes: 7 additions & 7 deletions examples/client/simple-publish.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const mqtt = require('../..')
const client = mqtt.connect()

client.publish('presence', 'hello!')
client.end()
'use strict'

const mqtt = require('../..')
const client = mqtt.connect()

client.publish('presence', 'hello!')
client.end()
4 changes: 2 additions & 2 deletions examples/wss/client_with_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ proxy: your proxy e.g. proxy.foo.bar.com
port: http proxy port e.g. 8080
*/
const proxy = process.env.http_proxy || 'http://<proxy>:<port>'
const parsed = url.parse(endpoint)
const proxyOpts = url.parse(proxy)
const parsed = url.URL(endpoint)
const proxyOpts = url.URL(proxy)
// true for wss
proxyOpts.secureEndpoint = parsed.protocol ? parsed.protocol === 'wss:' : true
const agent = new HttpsProxyAgent(proxyOpts)
Expand Down
Loading

0 comments on commit 2b5e31f

Please sign in to comment.