Example #1
0
func writeResponse(c *serverCodec) error {
	head := rpc.Response{}
	head.ServiceMethod = "TestFunc"
	head.Seq = 2
	head.Error = "call failed"

	body := testpb.Result{}
	body.Title = proto.String("www.zhihu.com")
	return c.WriteResponse(&head, &body)
}
Example #2
0
func readResponse(c *clientCodec) error {
	head := rpc.Response{}
	if err := c.ReadResponseHeader(&head); err != nil {
		return err
	}

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

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