Exemple #1
0
func (p *MsgResponseItem) WriteResponse(buf *bufio.Writer) error {

	v := 5
	if p.msg.UnlockTs > 0 {
		v = 6
	}

	err := enc.WriteDictSize(buf, v)
	_, err = buf.WriteString(" ID ")
	err = enc.WriteString(buf, p.msg.StrId)

	_, err = buf.WriteString(" PL ")
	err = enc.WriteBytes(buf, p.payload)

	_, err = buf.WriteString(" ETS ")
	err = enc.WriteInt64(buf, p.msg.ExpireTs)

	_, err = buf.WriteString(" POPCNT ")
	err = enc.WriteInt64(buf, p.msg.PopCount)

	_, err = buf.WriteString(" UTS ")
	err = enc.WriteInt64(buf, p.msg.UnlockTs)

	if p.msg.UnlockTs > 0 {
		_, err = buf.WriteString(" RCPT ")
		_, err = buf.WriteString(enc.EncodeTo36Base(p.msg.SerialNumber))
		err = buf.WriteByte('-')
		_, err = buf.WriteString(enc.EncodeTo36Base(uint64(p.msg.PopCount)))
	}
	return err
}
Exemple #2
0
func (r *IntResponse) WriteResponse(buf *bufio.Writer) error {
	_, err := buf.WriteString("+DATA ")
	enc.WriteInt64(buf, r.Value)
	return err
}