Search in sources :

Example 1 with LengthFieldPrepender

use of org.jboss.netty.handler.codec.frame.LengthFieldPrepender in project camel by apache.

the class MultipleCodecsTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    // START SNIPPET: registry-beans
    ChannelHandlerFactory lengthDecoder = ChannelHandlerFactories.newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4);
    StringDecoder stringDecoder = new StringDecoder();
    registry.bind("length-decoder", lengthDecoder);
    registry.bind("string-decoder", stringDecoder);
    LengthFieldPrepender lengthEncoder = new LengthFieldPrepender(4);
    StringEncoder stringEncoder = new StringEncoder();
    registry.bind("length-encoder", lengthEncoder);
    registry.bind("string-encoder", stringEncoder);
    List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
    decoders.add(lengthDecoder);
    decoders.add(stringDecoder);
    List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
    encoders.add(lengthEncoder);
    encoders.add(stringEncoder);
    registry.bind("encoders", encoders);
    registry.bind("decoders", decoders);
    // END SNIPPET: registry-beans
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) ArrayList(java.util.ArrayList) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ChannelHandler(org.jboss.netty.channel.ChannelHandler) LengthFieldPrepender(org.jboss.netty.handler.codec.frame.LengthFieldPrepender)

Example 2 with LengthFieldPrepender

use of org.jboss.netty.handler.codec.frame.LengthFieldPrepender in project graphdb by neo4j-attic.

the class Protocol method addLengthFieldPipes.

public static void addLengthFieldPipes(ChannelPipeline pipeline) {
    pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(MAX_FRAME_LENGTH + 4, 0, 4, 0, 4));
    pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));
}
Also used : LengthFieldPrepender(org.jboss.netty.handler.codec.frame.LengthFieldPrepender) LengthFieldBasedFrameDecoder(org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)

Example 3 with LengthFieldPrepender

use of org.jboss.netty.handler.codec.frame.LengthFieldPrepender in project neo4j by neo4j.

the class Protocol method addLengthFieldPipes.

public static void addLengthFieldPipes(ChannelPipeline pipeline, int frameLength) {
    pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(frameLength + 4, 0, 4, 0, 4));
    pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));
}
Also used : LengthFieldPrepender(org.jboss.netty.handler.codec.frame.LengthFieldPrepender) LengthFieldBasedFrameDecoder(org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)

Example 4 with LengthFieldPrepender

use of org.jboss.netty.handler.codec.frame.LengthFieldPrepender in project Terasology by MovingBlocks.

the class TerasologyServerPipelineFactory method getPipeline.

@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline p = pipeline();
    p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
    p.addLast("frameLengthEncoder", new LengthFieldPrepender(3));
    p.addLast("deflateEncoder", new ZlibEncoder());
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("authenticationHandler", new ServerHandshakeHandler());
    p.addLast("connectionHandler", new ServerConnectionHandler(networkSystem));
    p.addLast("handler", new ServerHandler(networkSystem));
    return p;
}
Also used : ZlibEncoder(org.jboss.netty.handler.codec.compression.ZlibEncoder) ProtobufEncoder(org.jboss.netty.handler.codec.protobuf.ProtobufEncoder) ServerConnectionHandler(org.terasology.network.internal.ServerConnectionHandler) ServerHandshakeHandler(org.terasology.network.internal.ServerHandshakeHandler) MetricRecordingHandler(org.terasology.network.internal.MetricRecordingHandler) ProtobufDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufDecoder) ProtobufVarint32LengthFieldPrepender(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender) ServerHandler(org.terasology.network.internal.ServerHandler) ProtobufVarint32LengthFieldPrepender(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender) LengthFieldPrepender(org.jboss.netty.handler.codec.frame.LengthFieldPrepender) ProtobufVarint32FrameDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Aggregations

LengthFieldPrepender (org.jboss.netty.handler.codec.frame.LengthFieldPrepender)4 LengthFieldBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)2 ArrayList (java.util.ArrayList)1 JndiRegistry (org.apache.camel.impl.JndiRegistry)1 ChannelHandler (org.jboss.netty.channel.ChannelHandler)1 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)1 ZlibEncoder (org.jboss.netty.handler.codec.compression.ZlibEncoder)1 ProtobufDecoder (org.jboss.netty.handler.codec.protobuf.ProtobufDecoder)1 ProtobufEncoder (org.jboss.netty.handler.codec.protobuf.ProtobufEncoder)1 ProtobufVarint32FrameDecoder (org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder)1 ProtobufVarint32LengthFieldPrepender (org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender)1 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)1 StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)1 MetricRecordingHandler (org.terasology.network.internal.MetricRecordingHandler)1 ServerConnectionHandler (org.terasology.network.internal.ServerConnectionHandler)1 ServerHandler (org.terasology.network.internal.ServerHandler)1 ServerHandshakeHandler (org.terasology.network.internal.ServerHandshakeHandler)1