From ffe24b95334969cbeb735580ac54d5d4c5155767 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Fri, 2 Aug 2024 15:25:44 -0700 Subject: [PATCH 1/3] Subscribe callback to also include the suback --- src/lib/client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/client.ts b/src/lib/client.ts index de0420137..fcdbdfafa 100644 --- a/src/lib/client.ts +++ b/src/lib/client.ts @@ -376,6 +376,7 @@ export type OnDisconnectCallback = (packet: IDisconnectPacket) => void export type ClientSubscribeCallback = ( err: Error | null, granted?: ISubscriptionGrant[], + packet?: ISubackPacket ) => void export type OnMessageCallback = ( topic: string, @@ -1241,7 +1242,7 @@ export default class MqttClient extends TypedEventEmitter Date: Fri, 2 Aug 2024 15:33:04 -0700 Subject: [PATCH 2/3] Lint --- src/lib/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/client.ts b/src/lib/client.ts index fcdbdfafa..5a82df1da 100644 --- a/src/lib/client.ts +++ b/src/lib/client.ts @@ -376,7 +376,7 @@ export type OnDisconnectCallback = (packet: IDisconnectPacket) => void export type ClientSubscribeCallback = ( err: Error | null, granted?: ISubscriptionGrant[], - packet?: ISubackPacket + packet?: ISubackPacket, ) => void export type OnMessageCallback = ( topic: string, From cd540c8b7d53a83bb0f0f75e42b956392b8ad024 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Mon, 5 Aug 2024 09:33:52 -0700 Subject: [PATCH 3/3] Update existing subscribe completion test with a suback check --- test/abstract_client.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/abstract_client.ts b/test/abstract_client.ts index d4441318a..1e38084df 100644 --- a/test/abstract_client.ts +++ b/test/abstract_client.ts @@ -2501,7 +2501,7 @@ export default function abstractTest(server, config, ports) { const topic = 'test' client.once('connect', () => { - client.subscribe(topic, { qos: 2 }, (err, granted) => { + client.subscribe(topic, { qos: 2 }, (err, granted, suback) => { if (err) { done(err) } else { @@ -2517,6 +2517,8 @@ export default function abstractTest(server, config, ports) { expectedResult.properties = undefined } assert.include(granted[0], expectedResult) + assert.exists(suback, 'suback not given') + assert.deepStrictEqual(suback.granted, [2]) client.end((err2) => done(err2)) } })