Search in sources :

Example 56 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project traccar by traccar.

the class TeltonikaProtocol 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 TeltonikaFrameDecoder());
            pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
            pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this, false));
        }
    });
    serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
            pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this, true));
        }
    });
}
Also used : TrackerServer(org.traccar.TrackerServer) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 57 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project traccar by traccar.

the class TaipProtocol 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, '<'));
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectDecoder", new TaipProtocolDecoder(TaipProtocol.this));
        }
    });
    serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectDecoder", new TaipProtocolDecoder(TaipProtocol.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)

Example 58 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project traccar by traccar.

the class VtfmsProtocol 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 VtfmsFrameDecoder());
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("objectDecoder", new VtfmsProtocolDecoder(VtfmsProtocol.this));
        }
    });
    serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("objectDecoder", new VtfmsProtocolDecoder(VtfmsProtocol.this));
        }
    });
}
Also used : 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)

Example 59 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project traccar by traccar.

the class Tk103Protocol 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 Tk103FrameDecoder());
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectEncoder", new Tk103ProtocolEncoder());
            pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(Tk103Protocol.this));
        }
    });
    serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {

        @Override
        protected void addSpecificHandlers(ChannelPipeline pipeline) {
            pipeline.addLast("stringDecoder", new StringDecoder());
            pipeline.addLast("stringEncoder", new StringEncoder());
            pipeline.addLast("objectEncoder", new Tk103ProtocolEncoder());
            pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(Tk103Protocol.this));
        }
    });
}
Also used : StringEncoder(org.jboss.netty.handler.codec.string.StringEncoder) 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)

Example 60 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project pinpoint by naver.

the class NettyUdpReceiverTest method server.

/*
    * netty io thread is single-threaded even for udp.
    * this is for running multiple workers.
    * */
@Test
public void server() throws IOException, InterruptedException {
    final ConnectionlessBootstrap udpServer = createUdpServer();
    Thread thread = new Thread(new Runnable() {

        @Override
        public void run() {
            udpServer.bind(new InetSocketAddress("127.0.0.1", PORT));
            try {
                logger.debug("server-await");
                latch.await();
            } catch (InterruptedException ignored) {
            }
            logger.debug("server-shutdown");
            udpServer.shutdown();
        }
    });
    thread.start();
    Thread.sleep(1000);
    logger.debug("start--------");
    // ExecutorService executorService = Executors.newFixedThreadPool(10);
    // for (int i =0; i< 10; i++) {
    // executorService.execute(new Runnable() {
    // @Override
    // public void run() {
    // try {
    start();
    // } catch (IOException e) {
    // e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    // }
    // }
    // });
    // }
    // executorService.awaitTermination(120, TimeUnit.SECONDS) ;
    latch.countDown();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap) Test(org.junit.Test)

Aggregations

ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)61 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)50 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)47 TrackerServer (org.traccar.TrackerServer)46 StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)24 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)20 NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)10 CharacterDelimiterFrameDecoder (org.traccar.CharacterDelimiterFrameDecoder)10 LengthFieldBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)8 InetSocketAddress (java.net.InetSocketAddress)7 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)4 FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)4 LineBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder)4 DatagramChannelFactory (org.jboss.netty.channel.socket.DatagramChannelFactory)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Channel (org.jboss.netty.channel.Channel)2 FixedLengthFrameDecoder (org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder)2 Test (org.junit.Test)2 ServerPipelineFactory (com.jcumulus.server.rtmfp.ServerPipelineFactory)1