commonMain.com.ditchoom.mqtt3.controlpacket.PublishAcknowledgment.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mqtt-4-models Show documentation
Show all versions of mqtt-4-models Show documentation
Defines the MQTT 3 and 4 control packets
package com.ditchoom.mqtt3.controlpacket
import com.ditchoom.buffer.ReadBuffer
import com.ditchoom.buffer.WriteBuffer
import com.ditchoom.mqtt.controlpacket.IPublishAcknowledgment
import com.ditchoom.mqtt.controlpacket.format.fixed.DirectionOfFlow
/**
* 3.4 PUBACK – Publish acknowledgement
*
* A PUBACK packet is the response to a PUBLISH packet with QoS 1.
*/
data class PublishAcknowledgment(override val packetIdentifier: Int) :
ControlPacketV4(IPublishAcknowledgment.controlPacketValue, DirectionOfFlow.BIDIRECTIONAL), IPublishAcknowledgment {
override fun remainingLength() = 2
override fun variableHeader(writeBuffer: WriteBuffer) {
writeBuffer.writeUShort(packetIdentifier.toUShort())
}
companion object {
fun from(buffer: ReadBuffer) = PublishAcknowledgment(buffer.readUnsignedShort().toInt())
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy