List of usage examples for io.netty.channel ChannelPipeline names
List<String> names();
From source file:co.marcin.novaguilds.impl.versionimpl.v1_8.PacketExtensionImpl.java
License:Open Source License
@Override public void registerPlayer(final Player player) { Channel c = getChannel(player); ChannelHandler handler = new ChannelDuplexHandler() { @Override/*from w w w. j a v a 2 s . co m*/ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg == null) { return; } super.write(ctx, msg, promise); } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { if (msg == null) { return; } PacketReceiveEvent event = callEvent(new PacketReceiveEvent(msg, player)); if (event.isCancelled() || event.getPacket() == null) { return; } super.channelRead(ctx, event.getPacket()); } catch (Exception e) { super.channelRead(ctx, msg); } } }; ChannelPipeline cp = c.pipeline(); if (cp.names().contains("packet_handler")) { if (cp.names().contains("NovaGuilds")) { cp.replace("NovaGuilds", "NovaGuilds", handler); } else { cp.addBefore("packet_handler", "NovaGuilds", handler); } } }
From source file:com.googlecode.protobuf.pro.duplex.example.execution.PipelineModifyingClient.java
License:Apache License
@Override public void execute(RpcClientChannel channel) { try {//from w ww.j a v a 2 s . c o m ChannelPipeline p = channel.getPipeline(); log.info("ChannelPipeline handlers: " + p.names()); } catch (Throwable t) { this.error = t; } }
From source file:io.moquette.spi.impl.ProtocolProcessor.java
License:Open Source License
private void setIdleTime(ChannelPipeline pipeline, int idleTime) { if (pipeline.names().contains("idleStateHandler")) { pipeline.remove("idleStateHandler"); }/*from w ww .j av a 2 s . c o m*/ pipeline.addFirst("idleStateHandler", new IdleStateHandler(0, 0, idleTime)); }
From source file:net.tomp2p.connection.Sender.java
License:Apache License
private boolean addOrReplace(ChannelPipeline pipeline, String before, String name, ChannelHandler channelHandler) { List<String> names = pipeline.names(); if (names.contains(name)) { pipeline.replace(name, name, channelHandler); return false; } else {/*from w w w. j a v a2 s. co m*/ if (before == null) { pipeline.addFirst(name, channelHandler); } else { pipeline.addBefore(before, name, channelHandler); } return true; } }