Skip to content

Commit ccf8142

Browse files
authored
Merge pull request #19 from LI-NA/LI-NA-patch-1
Add new methods, property and the test.
2 parents 199609d + a68afc5 commit ccf8142

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

index.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class AsyncClient {
2121
return this._client.connected;
2222
}
2323

24+
get reconnecting () {
25+
return this._client.reconnecting;
26+
}
27+
2428
publish (...args) {
2529
return new Promise((resolve, reject) => {
2630
this._client.publish(...args, (err, result) => {
@@ -69,6 +73,10 @@ class AsyncClient {
6973
return this._client.eventNames(...args);
7074
}
7175

76+
getLastMessageId (...args) {
77+
return this._client.getLastMessageId(...args);
78+
}
79+
7280
getMaxListeners (...args) {
7381
return this._client.getMaxListeners(...args);
7482
}
@@ -101,6 +109,10 @@ class AsyncClient {
101109
return this._client.prependOnceListener(...args);
102110
}
103111

112+
rawListeners (...args) {
113+
return this._client.rawListeners(...args);
114+
}
115+
104116
removeAllListeners (...args) {
105117
return this._client.removeAllListeners(...args);
106118
}
@@ -109,13 +121,14 @@ class AsyncClient {
109121
return this._client.removeListener(...args);
110122
}
111123

124+
removeOutgoingMessage (...args) {
125+
return this._client.removeOutgoingMessage(...args);
126+
}
127+
112128
setMaxListeners (...args) {
113129
return this._client.setMaxListeners(...args);
114130
}
115131

116-
rawListeners (...args) {
117-
return this._client.rawListeners(...args);
118-
}
119132
}
120133

121134

test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ function runTests () {
104104
return client.end();
105105
});
106106
});
107+
108+
test('Calling getLastMessageId should return number after published', t => {
109+
t.plan(1);
110+
111+
const client = AsyncMQTT.connect(SERVER_URL);
112+
113+
client.publish('example', 'test', {
114+
qos: 1
115+
}).then(() => {
116+
t.ok('number' === typeof client.getLastMessageId(), 'Message id is number');
117+
return client.end();
118+
});
119+
});
107120
}
108121

109122
// Taken from MQTT.js tests

0 commit comments

Comments
 (0)