public class NSHeadRpcProtocol extends AbstractProtocol
| 构造器和说明 |
|---|
NSHeadRpcProtocol(int protocol,
String encoding) |
| 限定符和类型 | 方法和说明 |
|---|---|
NSHeadPacket |
decode(DynamicCompositeByteBuf in)
客户端/服务端解析请求包成header+body buffer
|
void |
decodeRequest(Object in,
RpcRequest request)
服务端反序列化rpc请求
|
RpcResponse |
decodeResponse(Object in,
io.netty.channel.ChannelHandlerContext ctx)
客户端反序列化rpc响应
|
io.netty.buffer.ByteBuf |
encodeRequest(RpcRequest request)
客户端序列化请求对象
|
io.netty.buffer.ByteBuf |
encodeResponse(RpcResponse rpcResponse)
服务端序列化返回结果。
|
boolean |
returnChannelBeforeResponse()
连接被归还入池的时机
|
decodeHttpRequest, decodeHttpResponse, encodeHttpRequest, encodeHttpResponsepublic NSHeadRpcProtocol(int protocol,
String encoding)
public io.netty.buffer.ByteBuf encodeRequest(RpcRequest request) throws Exception
ProtocolencodeRequest 在接口中 ProtocolencodeRequest 在类中 AbstractProtocolrequest - 待发送给服务端的对象Exception - 序列化异常public RpcResponse decodeResponse(Object in, io.netty.channel.ChannelHandlerContext ctx) throws Exception
ProtocoldecodeResponse 在接口中 ProtocoldecodeResponse 在类中 AbstractProtocolin - header & body的bufctx - netty channel contextException - 反序列化异常public io.netty.buffer.ByteBuf encodeResponse(RpcResponse rpcResponse) throws Exception
ProtocolencodeResponse 在接口中 ProtocolencodeResponse 在类中 AbstractProtocolrpcResponse - 服务端要返回给客户端的对象Exception - 序列化异常public void decodeRequest(Object in, RpcRequest request) throws Exception
ProtocoldecodeRequest 在接口中 ProtocoldecodeRequest 在类中 AbstractProtocolin - header & body的bufExceptionpublic boolean returnChannelBeforeResponse()
ProtocolreturnChannelBeforeResponse 在接口中 ProtocolreturnChannelBeforeResponse 在类中 AbstractProtocolpublic NSHeadPacket decode(DynamicCompositeByteBuf in) throws BadSchemaException, TooBigDataException, NotEnoughDataException
Protocoldecode 在接口中 Protocoldecode 在类中 AbstractProtocolin - 输入byte bufBadSchemaException - header格式不对TooBigDataException - body太大NotEnoughDataException - 可读长度不够,由于粘包拆包问题。Copyright © 2018 Baidu, Inc.. All rights reserved.