emqx / CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
https://www.emqx.com/en
Other
1.58k stars 413 forks source link

calculate the Variable Length method seems wrong #462

Closed 1989allen126 closed 2 years ago

1989allen126 commented 2 years ago

beVariableByteInteger was wrong ///I try to changed func beVariableByteInteger(length: Int) -> [UInt8] { var res = [UInt8]() var tmpLen:Int = length repeat{ var d:UInt8 = UInt8(tmpLen % 128) tmpLen /= 128 if(tmpLen > 0) { d |= 0x80 } res.append(d) } while(tmpLen > 0)

return res

}