public class HuluRpcProtocol extends AbstractProtocol
body_size][meta_size
], 12 bytes in total
body_size and meta_size are NOT in
network byte order (little endian)
user_message_size is set iff request/response has attachment
notEnoughDataException| 构造器和说明 |
|---|
HuluRpcProtocol() |
| 限定符和类型 | 方法和说明 |
|---|---|
HuluRpcDecodePacket |
decode(io.netty.channel.ChannelHandlerContext ctx,
DynamicCompositeByteBuf in,
boolean isDecodingRequest)
客户端/服务端解析请求包成header+body buffer
|
Request |
decodeRequest(Object packet)
服务端反序列化rpc请求
|
Response |
decodeResponse(Object packet,
io.netty.channel.ChannelHandlerContext ctx)
客户端反序列化rpc响应
|
protected io.netty.buffer.ByteBuf |
encode(HuluRpcEncodePacket packet) |
io.netty.buffer.ByteBuf |
encodeRequest(Request request)
客户端序列化请求对象
|
io.netty.buffer.ByteBuf |
encodeResponse(Request request,
Response response)
服务端序列化返回结果。
|
boolean |
isCoexistence()
该协议是否可以和其他协议共存。
|
afterResponseSent, beforeRequestSent, createRequest, createResponse, getRequest, getResponse, returnChannelBeforeResponsepublic io.netty.buffer.ByteBuf encodeRequest(Request request) throws Exception
Protocolrequest - 待发送给服务端的对象Exception - 序列化异常public Response decodeResponse(Object packet, io.netty.channel.ChannelHandlerContext ctx) throws Exception
Protocolpacket - header & body的bufctx - netty channel contextException - 反序列化异常public Request decodeRequest(Object packet) throws Exception
Protocolpacket - header & body的bufExceptionpublic io.netty.buffer.ByteBuf encodeResponse(Request request, Response response) throws Exception
Protocolresponse - 服务端要返回给客户端的对象Exception - 序列化异常protected io.netty.buffer.ByteBuf encode(HuluRpcEncodePacket packet) throws IOException
IOExceptionpublic HuluRpcDecodePacket decode(io.netty.channel.ChannelHandlerContext ctx, DynamicCompositeByteBuf in, boolean isDecodingRequest) throws BadSchemaException, TooBigDataException, NotEnoughDataException
Protocolin - 输入byte bufBadSchemaException - header格式不对TooBigDataException - body太大NotEnoughDataException - 可读长度不够,由于粘包拆包问题。public boolean isCoexistence()
ProtocolisCoexistence 在接口中 ProtocolisCoexistence 在类中 AbstractProtocolCopyright © 2019 Baidu, Inc.. All rights reserved.