func (pkt *PublishPacket) WriteTo(w io.Writer, version byte) (n int, err error) {

	var d int
	n, err = pkt.Header().WriteTo(w)

	d, err = writeString(w, pkt.Topic)
	if err != nil {
		return
	}
	n += d
	if pkt.header.QoS > 0 {
		d, err = writeInt(w, pkt.ID)
		if err != nil {
			return
		}
		n += d
	}
	d, err = w.Write(pkt.Data)
	n += d
	return
}
// WriteTo writes the packet to the io.Writer.
WriteTo writes the packet to the io.Writer.
// WriteTo writes the packet to the io . Writer .
func (pkt *PublishPacket) WriteTo(w io.Writer, version byte) (n int, err error) {
	var d int
	n, err = pkt.Header().WriteTo(w)
	d, err = writeString(w, pkt.Topic)
	if err != nil {
		return
	}
	n += d
	if pkt.header.QoS > 0 {
		d, err = writeInt(w, pkt.ID)
		if err != nil {
			return
		}
		n += d
	}
	d, err = w.Write(pkt.Data)
	n += d
	return
}
func ( pkt * PublishPacket ) WriteTo ( w io . Writer , version byte ) ( n int , err error ) { var d int n , err = pkt . Header ( ) . WriteTo ( w ) d , err = writeString ( w , pkt . Topic ) if err != nil { return } n += d if pkt . header . QoS > 0 { d , err = writeInt ( w , pkt . ID ) if err != nil { return } n += d } d , err = w . Write ( pkt . Data ) n += d return }
WriteTo writes the packet to the io.Writer.
WriteTo writes the packet to the io . Writer .