func (c *codec) ReadBody(x interface{}, cr compressReader) error {
	dataSize := c.h.X.PacketSize - c.h.X.MetaSize
	if x == nil {
		_, err := c.r.Discard(int(dataSize))
		return err
	}

	msg := x.(proto.Message)

	var buf []byte
	var err error
	if cr != nil {
		// construct a compress reader
		rc, err := cr(io.LimitReader(c.r, int64(dataSize)))
		if err != nil {
			return err
		}
		// read all uncompressed data to buf
		buf, err = ioutil.ReadAll(rc)
		if err != nil {
			rc.Close()
			return err
		}
		rc.Close()
	} else {
		buf, err = c.readBuffer(int(dataSize))
		if err != nil {
			return err
		}
	}

	return proto.Unmarshal(buf, msg)
}
// ReadBody read rpc body from peer which corresponding to last rpc header
ReadBody read rpc body from peer which corresponding to last rpc header
// ReadBody read rpc body from peer which corresponding to last rpc header
func (c *codec) ReadBody(x interface{}, cr compressReader) error {
	dataSize := c.h.X.PacketSize - c.h.X.MetaSize
	if x == nil {
		_, err := c.r.Discard(int(dataSize))
		return err
	}
	msg := x.(proto.Message)
	var buf []byte
	var err error
	if cr != nil {
		rc, err := cr(io.LimitReader(c.r, int64(dataSize)))
		if err != nil {
			return err
		}
		buf, err = ioutil.ReadAll(rc)
		if err != nil {
			rc.Close()
			return err
		}
		rc.Close()
	} else {
		buf, err = c.readBuffer(int(dataSize))
		if err != nil {
			return err
		}
	}
	return proto.Unmarshal(buf, msg)
}
func ( c * codec ) ReadBody ( x interface { } , cr compressReader ) error { dataSize := c . h . X . PacketSize - c . h . X . MetaSize if x == nil { _ , err := c . r . Discard ( int ( dataSize ) ) return err } msg := x . ( proto . Message ) var buf [ ] byte var err error if cr != nil { rc , err := cr ( io . LimitReader ( c . r , int64 ( dataSize ) ) ) if err != nil { return err } buf , err = ioutil . ReadAll ( rc ) if err != nil { rc . Close ( ) return err } rc . Close ( ) } else { buf , err = c . readBuffer ( int ( dataSize ) ) if err != nil { return err } } return proto . Unmarshal ( buf , msg ) }
ReadBody read rpc body from peer which corresponding to last rpc header
ReadBody read rpc body from peer which corresponding to last rpc header
// construct a compress reader // read all uncompressed data to buf