Search in sources :

Example 1 with StringEncoder

use of io.netty.handler.codec.string.StringEncoder in project camel by apache.

the class NettyHttpGetWithInvalidMessageTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    // setup the String encoder and decoder 
    StringDecoder stringDecoder = new StringDecoder();
    registry.bind("string-decoder", stringDecoder);
    StringEncoder stringEncoder = new StringEncoder();
    registry.bind("string-encoder", stringEncoder);
    List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
    decoders.add(stringDecoder);
    List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
    encoders.add(stringEncoder);
    registry.bind("encoders", encoders);
    registry.bind("decoders", decoders);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) StringEncoder(io.netty.handler.codec.string.StringEncoder) ArrayList(java.util.ArrayList) StringDecoder(io.netty.handler.codec.string.StringDecoder) ChannelHandler(io.netty.channel.ChannelHandler)

Example 2 with StringEncoder

use of io.netty.handler.codec.string.StringEncoder in project benchmark by seelunzi.

the class ClientIniter method initChannel.

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline pipeline = socketChannel.pipeline();
    pipeline.addLast("stringD", new StringDecoder());
    pipeline.addLast("stringC", new StringEncoder());
    pipeline.addLast("http", new HttpClientCodec());
    pipeline.addLast("chat", new ChatClientHandler());
}
Also used : StringEncoder(io.netty.handler.codec.string.StringEncoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 3 with StringEncoder

use of io.netty.handler.codec.string.StringEncoder in project benchmark by seelunzi.

the class ServerIniterHandler method initChannel.

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline pipeline = socketChannel.pipeline();
    pipeline.addLast("docode", new StringDecoder());
    pipeline.addLast("encode", new StringEncoder());
    pipeline.addLast("chat", new ChatServerHandler());
}
Also used : StringEncoder(io.netty.handler.codec.string.StringEncoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 4 with StringEncoder

use of io.netty.handler.codec.string.StringEncoder in project pancm_project by xuwujing.

the class NettyClientFilter method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline ph = ch.pipeline();
    /*
         * 解码和编码,应和服务端一致
         * */
    // ph.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    ph.addLast("decoder", new StringDecoder());
    ph.addLast("encoder", new StringEncoder());
    // 客户端的逻辑
    ph.addLast("handler", new NettyClientHandler());
}
Also used : StringEncoder(io.netty.handler.codec.string.StringEncoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 5 with StringEncoder

use of io.netty.handler.codec.string.StringEncoder in project pancm_project by xuwujing.

the class NettyServerFilter method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline ph = ch.pipeline();
    // 以("\n")为结尾分割的 解码器
    // ph.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    // 解码和编码,应和客户端一致
    ph.addLast("decoder", new StringDecoder());
    ph.addLast("encoder", new StringEncoder());
    // 服务端业务逻辑
    ph.addLast("handler", new NettyServerHandler());
}
Also used : StringEncoder(io.netty.handler.codec.string.StringEncoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

StringEncoder (io.netty.handler.codec.string.StringEncoder)40 StringDecoder (io.netty.handler.codec.string.StringDecoder)37 ChannelPipeline (io.netty.channel.ChannelPipeline)28 SocketChannel (io.netty.channel.socket.SocketChannel)13 ChannelFuture (io.netty.channel.ChannelFuture)12 EventLoopGroup (io.netty.channel.EventLoopGroup)9 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)9 LengthFieldBasedFrameDecoder (io.netty.handler.codec.LengthFieldBasedFrameDecoder)9 LengthFieldPrepender (io.netty.handler.codec.LengthFieldPrepender)9 Bootstrap (io.netty.bootstrap.Bootstrap)8 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)8 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)7 Channel (io.netty.channel.Channel)7 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)7 DelimiterBasedFrameDecoder (io.netty.handler.codec.DelimiterBasedFrameDecoder)7 LineBasedFrameDecoder (io.netty.handler.codec.LineBasedFrameDecoder)7 NettyServerAndClient (org.apache.flink.runtime.io.network.netty.NettyTestUtil.NettyServerAndClient)5 Channel (org.apache.flink.shaded.netty4.io.netty.channel.Channel)5 SocketChannel (org.apache.flink.shaded.netty4.io.netty.channel.socket.SocketChannel)5 StringDecoder (org.apache.flink.shaded.netty4.io.netty.handler.codec.string.StringDecoder)5