Skip to content

Commit

Permalink
Fix the pos calculate wrong issue: #544
Browse files Browse the repository at this point in the history
  • Loading branch information
dahuayuan authored and leeway1208 committed Aug 15, 2023
1 parent 111a860 commit 0b911e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/FramePublish.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ extension FramePublish: InitialWithBytes {
if (protocolVersion == "5.0"){
let data = MqttDecodePublish()
data.decodePublish(fixedHeader: packetFixedHeaderType ,publishData: bytes)
pos += 1
pos = data.mqtt5DataIndex

if(data.propertyLength != 0){
pos += data.propertyLength!
Expand Down
3 changes: 2 additions & 1 deletion Source/MqttDecodePublish.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class MqttDecodePublish: NSObject {
public var topic: String = ""
//3.3.2.2 Packet Identifier
public var packetIdentifier: UInt16?

public var mqtt5DataIndex = 0


public func decodePublish(fixedHeader: UInt8, publishData: [UInt8]){
Expand Down Expand Up @@ -74,6 +74,7 @@ public class MqttDecodePublish: NSObject {
let propertyLengthVariableByteInteger = decodeVariableByteInteger(data: publishData, offset: dataIndex)
propertyLength = propertyLengthVariableByteInteger.res
dataIndex = propertyLengthVariableByteInteger.newOffset
mqtt5DataIndex = propertyLengthVariableByteInteger.newOffset

let occupyIndex = dataIndex

Expand Down

0 comments on commit 0b911e3

Please sign in to comment.