示例#1
0
func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	var req protorpcpb.Request
	if err := readFrame(c.rwc, &req); err != nil {
		return err
	}
	r.ServiceMethod = req.GetMethod()
	r.Seq = req.GetSeq()
	return nil
}
示例#2
0
func (c *clientCodec) WriteRequest(r *rpc.Request, body interface{}) error {
	var param proto.Message
	if body != nil {
		var ok bool
		if param, ok = body.(proto.Message); !ok {
			return fmt.Errorf("%T does not implement proto.Message", body)
		}
	}

	var req protorpcpb.Request
	req.Method = proto.String(r.ServiceMethod)
	req.Seq = proto.Uint64(r.Seq)
	return writeMessage(c.rwc, &req, param)
}