Skip to content

Commit bb2ab19

Browse files
committed
Add redundant topic filter strings on Unsubscribe packet for easier validation
1 parent e765ff4 commit bb2ab19

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/browser/mqtt_internal/model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export interface PubackPacketBinary extends IPacketBinary {
226226

227227
export interface SubscriptionBinary {
228228
topicFilter: ArrayBuffer;
229-
topicFilterAsString: string; // the one place we keep around a non-binary value
229+
topicFilterAsString: string; // keep around the non-binary value for easy validation
230230
qos: number;
231231
noLocal?: number;
232232
retainAsPublished?: number;
@@ -247,6 +247,7 @@ export interface UnsubscribePacketBinary extends IPacketBinary {
247247
packetId: number;
248248

249249
topicFilters: Array<ArrayBuffer>;
250+
topicFiltersAsStrings : Array<string>; // keep around the non-binary values for easy validation
250251

251252
userProperties?: Array<UserPropertyBinary>;
252253
}
@@ -569,11 +570,13 @@ function convertUnsubscribePacketToBinary(packet: UnsubscribePacketInternal, inc
569570
let binary_packet: UnsubscribePacketBinary = {
570571
type: mqtt5_packet.PacketType.Unsubscribe,
571572
packetId: 0,
572-
topicFilters: []
573+
topicFilters: [],
574+
topicFiltersAsStrings: []
573575
};
574576

575577
for (let topicFilter of packet.topicFilters) {
576578
binary_packet.topicFilters.push(encoder.encode(topicFilter).buffer);
579+
binary_packet.topicFiltersAsStrings.push(topicFilter);
577580
}
578581

579582
if (packet.userProperties != undefined) {

0 commit comments

Comments
 (0)