Example #1
0
func writeRequest(c *clientCodec) error {
	head := rpc.Request{}
	head.ServiceMethod = "TestFunc"
	head.Seq = 1

	body := testpb.Request{}
	body.Query = proto.String("ping www.tencent.com")
	return c.WriteRequest(&head, &body)
}
Example #2
0
func readRequest(c *serverCodec) error {
	head := rpc.Request{}
	if err := c.ReadRequestHeader(&head); err != nil {
		return err
	}

	body := testpb.Request{}
	if err := c.ReadRequestBody(&body); err != nil {
		return err
	}

	fmt.Printf("head: %v, body: %v\n", head, body.GetQuery())
	return nil
}