Search in sources :

Example 1 with NettyEncoder

use of com.duangframework.rpc.common.NettyEncoder in project duangframework by tcrct.

the class RpcChannelInitializer 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 NettyServiceHandler());
}
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) NettyServiceHandler(com.duangframework.rpc.handler.NettyServiceHandler) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 2 with NettyEncoder

use of com.duangframework.rpc.common.NettyEncoder 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)2 NettyEncoder (com.duangframework.rpc.common.NettyEncoder)2 ChannelPipeline (io.netty.channel.ChannelPipeline)2 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)2 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)2 NettyClientHandler (com.duangframework.rpc.handler.NettyClientHandler)1 NettyServiceHandler (com.duangframework.rpc.handler.NettyServiceHandler)1