Skip to content

Commit

Permalink
Issue 524 fix up
Browse files Browse the repository at this point in the history
  • Loading branch information
shamblett committed Jul 9, 2024
1 parent 7093bb2 commit a26d005
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class MqttConnectAckVariableHeader extends MqttVariableHeader {
@override
void readFrom(MqttByteBuffer variableHeaderStream) {
final ackConnectFlags = variableHeaderStream.readByte();
sessionPresent = ackConnectFlags == 1;
if (Protocol.version == MqttClientConstants.mqttV311ProtocolVersion) {
sessionPresent = ackConnectFlags == 1;
}
readReturnCode(variableHeaderStream);
}

Expand Down
6 changes: 4 additions & 2 deletions test/mqtt_client_connection_unsecure_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,14 @@ void main() {
final ch = SynchronousMqttServerConnectionHandler(clientEventBus,
maxConnectionAttempts: 3, socketOptions: socketOptions);
ch.onConnected = connectCb;
await ch.connect(mockBrokerAddress, mockBrokerPort,
final status = await ch.connect(mockBrokerAddress, mockBrokerPort,
MqttConnectMessage().withClientIdentifier(testClientId));
expect(ch.connectionStatus.state, MqttConnectionState.connected);
expect(ch.connectionStatus.returnCode,
MqttConnectReturnCode.connectionAccepted);
expect(ch.connectionStatus.connectAckMessage, isNotNull);
expect(
status.connectAckMessage?.variableHeader.sessionPresent, isFalse);
expect(connectCbCalled, isTrue);
final state = ch.disconnect();
expect(state, MqttConnectionState.disconnected);
Expand All @@ -269,7 +271,7 @@ void main() {
timeout: timeout));
});

test('Successful response and disconnect with returned status', () async {
test('Successful response and disconnect with session present', () async {
await IOOverrides.runZoned(() async {
Protocol.version = MqttClientConstants.mqttV311ProtocolVersion;
final clientEventBus = events.EventBus();
Expand Down

0 comments on commit a26d005

Please sign in to comment.