@qualithm/mqtt-wire - v0.1.5
    Preparing search index...

    Function decodePacket

    • Decode an MQTT packet from binary data.

      The version parameter is used for packets where the version affects the encoding (e.g., properties in 5.0). For CONNECT packets, the version is determined from the packet itself.

      Parameters

      • buffer: Uint8Array

        Buffer containing the packet

      • version: ProtocolVersion = "5.0"

        Protocol version (default: "5.0")

      • offset: number = 0

        Starting offset in buffer (default: 0)

      Returns DecodeResult<DecodedPacket>

      Decoded packet and bytes read

      const result = decodePacket(buffer, "5.0")
      if (result.ok) {
      console.log(result.value.packet.type)
      }