Search in sources :

Example 16 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project bigbluebutton by bigbluebutton.

the class AbstractOutboundPipelineFactory method getPipeline.

public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    // Add the text line codec combination first
    pipeline.addLast("encoder", new StringEncoder());
    // Note that outbound mode requires the decoder to treat many 'headers' as body lines
    pipeline.addLast("decoder", new EslFrameDecoder(8092, true));
    // Add an executor to ensure separate thread for each upstream message from here
    pipeline.addLast("executor", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
    // now the outbound client logic
    pipeline.addLast("clientHandler", makeHandler());
    return pipeline;
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) EslFrameDecoder(org.freeswitch.esl.client.transport.message.EslFrameDecoder) ExecutionHandler(org.freeswitch.esl.client.internal.debug.ExecutionHandler) OrderedMemoryAwareThreadPoolExecutor(org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Example 17 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project opennms by OpenNMS.

the class AsyncLineOrientedDetectorNettyImpl method appendToPipeline.

@Override
protected void appendToPipeline(ChannelPipeline retval) {
    // Upstream handlers
    retval.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, Delimiters.lineDelimiter()));
    retval.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8));
    retval.addLast("lineDecoder", new LineOrientedResponseDecoder());
    // Downstream handlers
    retval.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8));
    retval.addLast("lineEncoder", new LineOrientedRequestEncoder());
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) DelimiterBasedFrameDecoder(org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) LineOrientedRequestEncoder(org.opennms.netmgt.provision.detector.simple.support.LineOrientedRequestEncoder) LineOrientedResponseDecoder(org.opennms.netmgt.provision.detector.simple.support.LineOrientedResponseDecoder)

Example 18 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project yyl_example by Relucent.

the class NettyServer method main.

public static void main(String[] args) {
    ServerBootstrap bootstrap = new //
    ServerBootstrap(new //
    NioServerSocketChannelFactory(// boss
    Executors.newCachedThreadPool(), // worker
    Executors.newCachedThreadPool()));
    // Set up the default event pipeline.
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline(new StringDecoder(), new StringEncoder(), new ServerHandler());
        }
    });
    // Bind and start to accept incoming connections.
    Channel bind = bootstrap.bind(new InetSocketAddress(8000));
    System.out.println("Server started, listening port: " + bind.getLocalAddress() + ", Waiting for client register...");
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) InetSocketAddress(java.net.InetSocketAddress) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap)

Example 19 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project traccar by tananaev.

the class MeitrackProtocol method initTrackerServers.

@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("frameDecoder", new MeitrackFrameDecoder());
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
            pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
        }
    };
    server.setEndianness(ByteOrder.LITTLE_ENDIAN);
    serverList.add(server);
    server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
            pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
        }
    };
    server.setEndianness(ByteOrder.LITTLE_ENDIAN);
    serverList.add(server);
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) TrackerServer(org.traccar.TrackerServer) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 20 with StringEncoder

use of org.jboss.netty.handler.codec.string.StringEncoder in project traccar by tananaev.

the class Gl100Protocol method initTrackerServers.

@Override
public void initTrackerServers(List<TrackerServer> serverList) {
    serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\0'));
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(Gl100Protocol.this));
        }
    });
    serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(Gl100Protocol.this));
        }
    });
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) CharacterDelimiterFrameDecoder(org.traccar.CharacterDelimiterFrameDecoder) StringDecoder(org.jboss.netty.handler.codec.string.StringDecoder) TrackerServer(org.traccar.TrackerServer) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Aggregations

StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)24 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)18 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)17 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)16 TrackerServer (org.traccar.TrackerServer)15 ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)12 CharacterDelimiterFrameDecoder (org.traccar.CharacterDelimiterFrameDecoder)5 JndiRegistry (org.apache.camel.impl.JndiRegistry)3 InetSocketAddress (java.net.InetSocketAddress)2 ArrayList (java.util.ArrayList)2 ExecutionHandler (org.freeswitch.esl.client.internal.debug.ExecutionHandler)2 EslFrameDecoder (org.freeswitch.esl.client.transport.message.EslFrameDecoder)2 ChannelHandler (org.jboss.netty.channel.ChannelHandler)2 DelimiterBasedFrameDecoder (org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder)2 LineBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder)2 OrderedMemoryAwareThreadPoolExecutor (org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor)2 LineOrientedRequestEncoder (org.opennms.netmgt.provision.detector.simple.support.LineOrientedRequestEncoder)2 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)1