Пример #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
}
Пример #2
0
func NewServiceDescription(name, sType string, exportId uint64) *ServiceDescription {
	return &ServiceDescription{
		ExportId:  exportId,
		SType:     sType,
		Name:      name,
		CreateTs:  utils.Uts(),
		Disabled:  false,
		ToDelete:  false,
		ServiceId: enc.EncodeTo36Base(exportId),
	}
}
Пример #3
0
func (p *MsgResponseItem) Receipt() string {
	return enc.EncodeTo36Base(p.msg.SerialNumber) + "-" + enc.EncodeTo36Base(uint64(p.msg.PopCount))
}