vrpc 3.13.0 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +100 -77
- package/browser/vrpc.js +5 -5
- package/index.js +7 -7
- package/package.json +25 -15
- package/vrpc/ReconnectBackoff.js +79 -0
- package/vrpc/Registrations.js +850 -0
- package/vrpc/SubscribeRetrier.js +33 -0
- package/vrpc/VrpcAdapter.js +552 -294
- package/vrpc/VrpcAgent.js +242 -154
- package/vrpc/VrpcBrowserAdapter.js +417 -285
- package/vrpc/VrpcBrowserAgent.js +239 -128
- package/vrpc/VrpcClient.js +1221 -233
- package/vrpc/VrpcNative.js +10 -5
- package/vrpc/VrpcPersistor.js +1 -1
- package/vrpc/adapter.hpp +1 -1
- package/vrpc/addon.cpp +1 -1
- package/vrpc/comment-parser/parser.js +23 -0
- package/vrpc/namePattern.js +86 -0
- package/vrpc/vrpc-agent-js +3 -11
package/vrpc/SubscribeRetrier.js
CHANGED
|
@@ -93,6 +93,39 @@ class SubscribeRetrier {
|
|
|
93
93
|
this._attempt = 0
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* What a SUBACK said, however mqtt.js reports it. mqtt.js 5 turns a
|
|
98
|
+
* refused topic (reason code 0x80 and up) into an error carrying the
|
|
99
|
+
* SUBACK packet, and hands back the subscriptions as requested; older
|
|
100
|
+
* versions answered `qos: 128` in the granted list.
|
|
101
|
+
*
|
|
102
|
+
* @param {Error|null} err The subscribe callback's error
|
|
103
|
+
* @param {Array.<Object>} granted The subscribe callback's `{ topic, qos }`
|
|
104
|
+
* @returns {Object} `{ refused, granted, error }`: the refused topics, the
|
|
105
|
+
* granted `{ topic, qos }`, and an error that is no refusal (or null)
|
|
106
|
+
*/
|
|
107
|
+
static outcome (err, granted) {
|
|
108
|
+
const subs = Array.isArray(granted) ? granted : []
|
|
109
|
+
const codes = err && err.packet && Array.isArray(err.packet.granted)
|
|
110
|
+
? err.packet.granted
|
|
111
|
+
: null
|
|
112
|
+
if (codes) {
|
|
113
|
+
const refused = []
|
|
114
|
+
const ok = []
|
|
115
|
+
subs.forEach(({ topic }, i) => {
|
|
116
|
+
if ((codes[i] & 0x80) !== 0) refused.push(topic)
|
|
117
|
+
else ok.push({ topic, qos: codes[i] })
|
|
118
|
+
})
|
|
119
|
+
return { refused, granted: ok, error: null }
|
|
120
|
+
}
|
|
121
|
+
if (err) return { refused: [], granted: [], error: err }
|
|
122
|
+
return {
|
|
123
|
+
refused: subs.filter(x => x.qos === 128).map(x => x.topic),
|
|
124
|
+
granted: subs.filter(x => x.qos !== 128),
|
|
125
|
+
error: null
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
96
129
|
_fire () {
|
|
97
130
|
this._timer = null
|
|
98
131
|
this._attempt += 1
|