예제 #1
0
// ReadIn reads the frame from the given io.Reader
func (f *Frame) ReadIn(r io.Reader) error {
	var rbuf typed.ReadBuffer
	rbuf.Wrap(f.headerBuffer)

	if _, err := rbuf.FillFrom(r, FrameHeaderSize); err != nil {
		return err
	}

	if err := f.Header.read(&rbuf); err != nil {
		return err
	}
	if f.Header.PayloadSize() > 0 {
		if _, err := io.ReadFull(r, f.SizedPayload()); err != nil {
			return err
		}
	}

	return nil
}