Search in sources :

Example 1 with NettyClientHandler

use of com.duangframework.rpc.handler.NettyClientHandler in project duangframework by tcrct.

the class ClientChannelInitializer method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    // 将 RPC 请求进行解码(为了处理请求)
    p.addLast(new NettyDecoder());
    // // 将 RPC 响应进行编码(为了返回响应)
    p.addLast(new NettyEncoder());
    // 目的是支持异步大文件传输
    p.addLast(new ChunkedWriteHandler());
    p.addLast(new IdleStateHandler(60, 0, 0));
    // 真正处理RPC业务逻辑的地方
    p.addLast(new NettyClientHandler());
}
Also used : ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) NettyEncoder(com.duangframework.rpc.common.NettyEncoder) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) NettyDecoder(com.duangframework.rpc.common.NettyDecoder) NettyClientHandler(com.duangframework.rpc.handler.NettyClientHandler) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

NettyDecoder (com.duangframework.rpc.common.NettyDecoder)1 NettyEncoder (com.duangframework.rpc.common.NettyEncoder)1 NettyClientHandler (com.duangframework.rpc.handler.NettyClientHandler)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)1 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)1