Search in sources :

Example 1 with OpenChannelHandler

use of org.traccar.handler.OpenChannelHandler in project traccar by tananaev.

the class BasePipelineFactory method initChannel.

@Override
protected void initChannel(Channel channel) {
    final ChannelPipeline pipeline = channel.pipeline();
    addTransportHandlers(pipeline::addLast);
    if (timeout > 0 && !connector.isDatagram()) {
        pipeline.addLast(new IdleStateHandler(timeout, 0, 0));
    }
    pipeline.addLast(new OpenChannelHandler(connector));
    pipeline.addLast(new NetworkMessageHandler());
    pipeline.addLast(new StandardLoggingHandler(protocol));
    addProtocolHandlers(handler -> {
        if (!(handler instanceof BaseProtocolDecoder || handler instanceof BaseProtocolEncoder)) {
            if (handler instanceof ChannelInboundHandler) {
                handler = new WrapperInboundHandler((ChannelInboundHandler) handler);
            } else {
                handler = new WrapperOutboundHandler((ChannelOutboundHandler) handler);
            }
        }
        pipeline.addLast(handler);
    });
    addHandlers(pipeline, TimeHandler.class, GeolocationHandler.class, HemisphereHandler.class, DistanceHandler.class, RemoteAddressHandler.class, FilterHandler.class, GeocoderHandler.class, SpeedLimitHandler.class, MotionHandler.class, CopyAttributesHandler.class, EngineHoursHandler.class, ComputedAttributesHandler.class, WebDataHandler.class, DefaultDataHandler.class, CommandResultEventHandler.class, OverspeedEventHandler.class, BehaviorEventHandler.class, FuelDropEventHandler.class, MotionEventHandler.class, GeofenceEventHandler.class, AlertEventHandler.class, IgnitionEventHandler.class, MaintenanceEventHandler.class, DriverEventHandler.class);
    pipeline.addLast(new MainEventHandler());
}
Also used : ChannelOutboundHandler(io.netty.channel.ChannelOutboundHandler) NetworkMessageHandler(org.traccar.handler.NetworkMessageHandler) OpenChannelHandler(org.traccar.handler.OpenChannelHandler) ChannelPipeline(io.netty.channel.ChannelPipeline) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) StandardLoggingHandler(org.traccar.handler.StandardLoggingHandler) ChannelInboundHandler(io.netty.channel.ChannelInboundHandler)

Aggregations

ChannelInboundHandler (io.netty.channel.ChannelInboundHandler)1 ChannelOutboundHandler (io.netty.channel.ChannelOutboundHandler)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)1 NetworkMessageHandler (org.traccar.handler.NetworkMessageHandler)1 OpenChannelHandler (org.traccar.handler.OpenChannelHandler)1 StandardLoggingHandler (org.traccar.handler.StandardLoggingHandler)1