Exemple #1
0
func parseSymbol(data []byte) packet.OptionId {
	errs.Check(len(data) >= 6)
	var b [8]byte
	copy(b[:], data)
	oid := packet.OptionIdFromUint64(binary.LittleEndian.Uint64(b[:]))
	return oid
}
Exemple #2
0
func (o *optionId) UnmarshalFlag(value string) (err error) {
	defer errs.PassE(&err)
	v, err := strconv.ParseUint(value, 0, 64)
	errs.CheckE(err)
	o.OptionId = packet.OptionIdFromUint64(v)
	return
}
Exemple #3
0
func (s *Subscr) SubscribeFromReader(rd io.Reader) (err error) {
	defer errs.PassE(&err)
	sc := bufio.NewScanner(rd)
	for sc.Scan() {
		text := sc.Text()
		var v uint64
		var b byte
		if _, err := fmt.Sscanf(text, "%c%v", &b, &v); err != nil {
			_, err = fmt.Sscanf(text, "%v", &v)
			errs.CheckE(err)
		}
		oid := packet.OptionIdFromUint64(v)
		if b == 'U' || b == 'u' || b == '!' {
			if s.autoSubscribe {
				s.stoplist[oid] = struct{}{}
			} else {
				s.Unsubscribe(oid)
			}
		} else {
			s.Subscribe(oid)
		}
	}
	errs.CheckE(sc.Err())
	return
}