func (c *Client) ReadFixedHeader(fh *packets.FixedHeader) error {
	p, err := c.r.Read(1)
	if err != nil {
		return err
	}

	err = fh.Decode(p[0])
	if err != nil {
		return err
	}

	// The remaining length value can be up to 5 bytes. Read through each byte
	// looking for continue values, and if found increase the read. Otherwise
	// decode the bytes that were legit.
	buf := make([]byte, 0, 6)
	i := 1
	n := 2
	for ; n < 6; n++ {
		p, err = c.r.Read(n)
		if err != nil {
			return err
		}

		buf = append(buf, p[i])

		// If it's not a continuation flag, end here.
		if p[i] < 128 {
			break
		}

		// If i has reached 4 without a length terminator, return a protocol violation.
		i++
		if i == 4 {
			return packets.ErrOversizedLengthIndicator
		}
	}

	// Calculate and store the remaining length of the packet payload.
	rem, _ := binary.Uvarint(buf)
	fh.Remaining = int(rem)

	// Having successfully read n bytes, commit the tail forward.
	c.r.CommitTail(n)
	atomic.AddInt64(&c.system.BytesRecv, int64(n))

	return nil
}
// readFixedHeader reads in the values of the next packet's fixed header.
readFixedHeader reads in the values of the next packet's fixed header.
// readFixedHeader reads in the values of the next packet ' s fixed header .
func (c *Client) ReadFixedHeader(fh *packets.FixedHeader) error {
	p, err := c.r.Read(1)
	if err != nil {
		return err
	}
	err = fh.Decode(p[0])
	if err != nil {
		return err
	}
	buf := make([]byte, 0, 6)
	i := 1
	n := 2
	for ; n < 6; n++ {
		p, err = c.r.Read(n)
		if err != nil {
			return err
		}
		buf = append(buf, p[i])
		if p[i] < 128 {
			break
		}
		i++
		if i == 4 {
			return packets.ErrOversizedLengthIndicator
		}
	}
	rem, _ := binary.Uvarint(buf)
	fh.Remaining = int(rem)
	c.r.CommitTail(n)
	atomic.AddInt64(&c.system.BytesRecv, int64(n))
	return nil
}
func ( c * Client ) ReadFixedHeader ( fh * packets . FixedHeader ) error { p , err := c . r . Read ( 1 ) if err != nil { return err } err = fh . Decode ( p [ 0 ] ) if err != nil { return err } buf := make ( [ ] byte , 0 , 6 ) i := 1 n := 2 for ; n < 6 ; n ++ { p , err = c . r . Read ( n ) if err != nil { return err } buf = append ( buf , p [ i ] ) if p [ i ] < 128 { break } i ++ if i == 4 { return packets . ErrOversizedLengthIndicator } } rem , _ := binary . Uvarint ( buf ) fh . Remaining = int ( rem ) c . r . CommitTail ( n ) atomic . AddInt64 ( & c . system . BytesRecv , int64 ( n ) ) return nil }
readFixedHeader reads in the values of the next packet's fixed header.
readFixedHeader reads in the values of the next packet ' s fixed header .
// The remaining length value can be up to 5 bytes. Read through each byte // looking for continue values, and if found increase the read. Otherwise // decode the bytes that were legit. // If it's not a continuation flag, end here. // If i has reached 4 without a length terminator, return a protocol violation. // Calculate and store the remaining length of the packet payload. // Having successfully read n bytes, commit the tail forward.