Skip to content

Commit d1d2383

Browse files
authored
Merge branch 'main' into more-client-end-test-changes
2 parents 1a7a5bb + 31dd357 commit d1d2383

23 files changed

+3424
-3296
lines changed

.airtap.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
providers:
2+
- airtap-playwright
3+
ui: mocha-bdd
4+
browsers:
5+
- name: chromium
6+
supports:
7+
headless: true
8+

.airtaprc.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/mqttjs-test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,12 @@ jobs:
4242
env:
4343
CI: true
4444
DEBUG: "mqttjs"
45+
46+
- name: Test Browser
47+
timeout-minutes: 2
48+
run: |
49+
npm run browser-build
50+
npm run unit-test:browser
51+
4552

4653

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ test/typescript/*.js
1717
test/typescript/*.map
1818
# VS Code stuff
1919
**/typings/**
20-
20+
.vscode/
2121
.npmrc
22+

examples/ws/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const host = 'ws://localhost:8080'
1515

1616
const options = {
1717
keepalive: 30,
18-
clientId: clientId,
18+
clientId,
1919
protocolId: 'MQTT',
2020
protocolVersion: 4,
2121
clean: true,

examples/wss/client_with_proxy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const proxyOpts = url.parse(proxy)
2121
proxyOpts.secureEndpoint = parsed.protocol ? parsed.protocol === 'wss:' : true
2222
const agent = new HttpsProxyAgent(proxyOpts)
2323
const wsOptions = {
24-
agent: agent
24+
agent
2525
// other wsOptions
2626
// foo:'bar'
2727
}
@@ -34,7 +34,7 @@ const mqttOptions = {
3434
connectTimeout: 30 * 1000,
3535
clean: true,
3636
clientId: 'testClient',
37-
wsOptions: wsOptions
37+
wsOptions
3838
}
3939

4040
const client = mqtt.connect(parsed, mqttOptions)

lib/client.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,11 @@ MqttClient.prototype.publish = function (topic, message, opts, callback) {
638638
}
639639
const packet = {
640640
cmd: 'publish',
641-
topic: topic,
641+
topic,
642642
payload: message,
643643
qos: opts.qos,
644644
retain: opts.retain,
645-
messageId: messageId,
645+
messageId,
646646
dup: opts.dup
647647
}
648648

@@ -675,7 +675,7 @@ MqttClient.prototype.publish = function (topic, message, opts, callback) {
675675
{
676676
invoke: publishProc,
677677
cbStorePut: opts.cbStorePut,
678-
callback: callback
678+
callback
679679
}
680680
)
681681
}
@@ -750,7 +750,7 @@ MqttClient.prototype.subscribe = function () {
750750
that._resubscribeTopics[topic].qos < opts.qos ||
751751
resubscribe) {
752752
const currentOpts = {
753-
topic: topic,
753+
topic,
754754
qos: opts.qos
755755
}
756756
if (version === 5) {
@@ -805,7 +805,7 @@ MqttClient.prototype.subscribe = function () {
805805
qos: 1,
806806
retain: false,
807807
dup: false,
808-
messageId: messageId
808+
messageId
809809
}
810810

811811
if (opts.properties) {
@@ -854,7 +854,7 @@ MqttClient.prototype.subscribe = function () {
854854
this._storeProcessingQueue.push(
855855
{
856856
invoke: subscribeProc,
857-
callback: callback
857+
callback
858858
}
859859
)
860860
}
@@ -911,7 +911,7 @@ MqttClient.prototype.unsubscribe = function () {
911911
const packet = {
912912
cmd: 'unsubscribe',
913913
qos: 1,
914-
messageId: messageId
914+
messageId
915915
}
916916

917917
if (typeof topic === 'string') {
@@ -945,7 +945,7 @@ MqttClient.prototype.unsubscribe = function () {
945945
this._storeProcessingQueue.push(
946946
{
947947
invoke: unsubscribeProc,
948-
callback: callback
948+
callback
949949
}
950950
)
951951
}
@@ -1054,7 +1054,7 @@ MqttClient.prototype.end = function (force, opts, cb) {
10541054
MqttClient.prototype.removeOutgoingMessage = function (messageId) {
10551055
const cb = this.outgoing[messageId] ? this.outgoing[messageId].cb : null
10561056
delete this.outgoing[messageId]
1057-
this.outgoingStore.del({ messageId: messageId }, function () {
1057+
this.outgoingStore.del({ messageId }, function () {
10581058
cb(new Error('Message removed'))
10591059
})
10601060
return this
@@ -1297,7 +1297,7 @@ MqttClient.prototype._storePacket = function (packet, cb, cbStorePut) {
12971297
}
12981298
// check that the packet is not a qos of 0, or that the command is not a publish
12991299
if (((storePacket.qos || 0) === 0 && this.queueQoSZero) || storePacket.cmd !== 'publish') {
1300-
this.queue.push({ packet: storePacket, cb: cb })
1300+
this.queue.push({ packet: storePacket, cb })
13011301
} else if (storePacket.qos > 0) {
13021302
cb = this.outgoing[storePacket.messageId] ? this.outgoing[storePacket.messageId].cb : null
13031303
this.outgoingStore.put(storePacket, function (err) {
@@ -1533,10 +1533,10 @@ MqttClient.prototype._handlePublish = function (packet, done) {
15331533
if (error) { return that.emit('error', error) }
15341534
if (validReasonCodes.indexOf(code) === -1) { return that.emit('error', new Error('Wrong reason code for pubrec')) }
15351535
if (code) {
1536-
that._sendPacket({ cmd: 'pubrec', messageId: messageId, reasonCode: code }, done)
1536+
that._sendPacket({ cmd: 'pubrec', messageId, reasonCode: code }, done)
15371537
} else {
15381538
that.incomingStore.put(packet, function () {
1539-
that._sendPacket({ cmd: 'pubrec', messageId: messageId }, done)
1539+
that._sendPacket({ cmd: 'pubrec', messageId }, done)
15401540
})
15411541
}
15421542
})
@@ -1556,7 +1556,7 @@ MqttClient.prototype._handlePublish = function (packet, done) {
15561556
if (err) {
15571557
return done && done(err)
15581558
}
1559-
that._sendPacket({ cmd: 'puback', messageId: messageId, reasonCode: code }, done)
1559+
that._sendPacket({ cmd: 'puback', messageId, reasonCode: code }, done)
15601560
})
15611561
})
15621562
break
@@ -1642,7 +1642,7 @@ MqttClient.prototype._handleAck = function (packet) {
16421642
response = {
16431643
cmd: 'pubrel',
16441644
qos: 2,
1645-
messageId: messageId
1645+
messageId
16461646
}
16471647
const pubrecRC = packet.reasonCode
16481648

@@ -1703,7 +1703,7 @@ MqttClient.prototype._handlePubrel = function (packet, callback) {
17031703
const messageId = packet.messageId
17041704
const that = this
17051705

1706-
const comp = { cmd: 'pubcomp', messageId: messageId }
1706+
const comp = { cmd: 'pubcomp', messageId }
17071707

17081708
that.incomingStore.get(packet, function (err, pub) {
17091709
if (!err) {

lib/connect/ali.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function buildStream (client, opts) {
114114
const url = buildUrl(opts, client)
115115
my = opts.my
116116
my.connectSocket({
117-
url: url,
117+
url,
118118
protocols: websocketSubProtocol
119119
})
120120

lib/connect/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const MqttClient = require('../client')
44
const Store = require('../store')
55
const DefaultMessageIdProvider = require('../default-message-id-provider')
66
const UniqueMessageIdProvider = require('../unique-message-id-provider')
7-
const IS_BROWSER = require('../is-browser').IS_BROWSER
7+
const { IS_BROWSER } = require('../is-browser')
88
const url = require('url')
99
const xtend = require('xtend')
1010
const debug = require('debug')('mqttjs')

lib/connect/ws.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const WS = require('ws')
55
const debug = require('debug')('mqttjs:ws')
66
const duplexify = require('duplexify')
77
const Transform = require('readable-stream').Transform
8-
const IS_BROWSER = require('../is-browser').IS_BROWSER
8+
const { IS_BROWSER } = require('../is-browser')
99

1010
const WSS_OPTIONS = [
1111
'rejectUnauthorized',
@@ -100,9 +100,9 @@ function createWebSocket (client, url, opts) {
100100

101101
function createBrowserWebSocket (client, opts) {
102102
const websocketSubProtocol =
103-
(opts.protocolId === 'MQIsdp') && (opts.protocolVersion === 3)
104-
? 'mqttv3.1'
105-
: 'mqtt'
103+
(opts.protocolId === 'MQIsdp') && (opts.protocolVersion === 3)
104+
? 'mqttv3.1'
105+
: 'mqtt'
106106

107107
const url = buildUrl(opts, client)
108108
/* global WebSocket */

0 commit comments

Comments
 (0)