Skip to content

Commit f66f815

Browse files
author
Bret Ambrose
committed
Validate disconnect before submitting; some tests will fail
1 parent a9024f5 commit f66f815

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/browser/mqtt5.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {CrtError} from "./error";
2121
import * as ws from "./ws";
2222
import * as mqtt_shared from "../common/mqtt_shared";
2323
import * as auth from "./auth";
24+
import * as validate from "./mqtt_internal/validate";
2425

2526
export * from "../common/mqtt5";
2627
export * from '../common/mqtt5_packet';
@@ -373,6 +374,12 @@ export class Mqtt5Client extends BufferedEventEmitter implements mqtt5.IMqtt5Cli
373374
* @param disconnectPacket (optional) properties of a DISCONNECT packet to send as part of the shutdown process
374375
*/
375376
stop(disconnectPacket?: mqtt5_packet.DisconnectPacket) {
377+
// maintain backwards comaptibility with previous implementation which let validation errors
378+
// trump the stop request
379+
if (disconnectPacket) {
380+
validate.validateInitialOutboundPacket(disconnectPacket, internal_mqtt_client.ProtocolMode.Mqtt5);
381+
}
382+
376383
this.internalClient.stop(disconnectPacket);
377384
}
378385

0 commit comments

Comments
 (0)