本文整理汇总了Java中io.netty.channel.ChannelPipeline.addAfter方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelPipeline.addAfter方法的具体用法?Java ChannelPipeline.addAfter怎么用?Java ChannelPipeline.addAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.channel.ChannelPipeline
的用法示例。
在下文中一共展示了ChannelPipeline.addAfter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encode
import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, ConnectionResponse msg, ByteBuf out) throws Exception {
ChannelPipeline pipeline = ctx.pipeline();
switch (msg.getType()) {
case HANDSHAKE_CONNECTION:
pipeline.addAfter("decoder", "handshake.encoder", new HandshakeEncoder());
pipeline.replace("decoder", "handshake.decoder", new HandshakeDecoder());
break;
case LOGIN_CONNECTION:
out.writeByte(ClientMessage.SUCCESSFUL_CONNECTION.getId());
pipeline.addAfter("decoder", "login.encoder", new LoginEncoder());
pipeline.replace("decoder", "login.decoder", new LoginDecoder());
break;
}
pipeline.remove(this);
}
示例2: handleMessage
import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
public void handleMessage(ChannelHandlerContext ctx, WorldLoginRequest msg) {
ClientMessage message = evaluateLogin(msg);
if (message != ClientMessage.SUCCESSFUL) {
ctx.write(new WorldLoginResponse(message));
return;
}
Player player = new Player(ctx.channel());
ctx.write(new WorldLoginResponse(player, message, msg.getIsaacPair()));
ChannelPipeline pipeline = ctx.pipeline();
pipeline.remove("login.encoder");
// this isnt set automatically.
pipeline.addAfter("world.decoder", "game.encoder", new GamePacketEncoder(msg.getIsaacPair().getEncoderRandom()));
pipeline.replace("world.decoder", "game.decoder", new GamePacketDecoder(player, msg.getIsaacPair().getDecoderRandom()));
player.init(msg.getDisplayInformation());
}
示例3: handlerAdded
import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
super.handlerAdded(ctx);
ChannelPipeline cp = ctx.pipeline();
if (cp.get(ShadowsocksRequestEncoder.class) == null) {
cp.addAfter(ctx.name(), ShadowsocksRequestEncoder.class.getName(),
ShadowsocksRequestEncoder.INSTANCE);
}
}
示例4: encode
import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, LoginResponse msg, ByteBuf out) throws Exception {
ClientMessage message = msg.getMessage();
ChannelPipeline pipeline = ctx.pipeline();
if (message != ClientMessage.SUCCESSFUL) {
// dont write the id for successful.
out.writeByte(message.getId());
} else {
pipeline.addAfter("login.decoder", "world.encoder", new WorldLoginEncoder());
pipeline.replace("login.decoder", "world.decoder", new WorldLoginDecoder(msg.getType()));
}
pipeline.remove(this);
}
示例5: encode
import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, HandshakeResponse msg, ByteBuf out) throws Exception {
ChannelPipeline pipeline = ctx.pipeline();
ClientMessage message = msg.getMessage();
out.writeByte(message.getId());
if (message == ClientMessage.SUCCESSFUL_CONNECTION) {
pipeline.addAfter("handshake.decoder", "xor.encrypt", new XOREncryptionEncoder());
pipeline.addAfter("xor.encrypt", "update.encoder", new UpdateEncoder());
pipeline.replace("handshake.decoder", "update.decoder", new UpdateDecoder());
}
pipeline.remove(this);
}
示例6: addClientHandlers
import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
private static void addClientHandlers()
{
ChannelPipeline pipeline = channelPair.get(Side.CLIENT).pipeline();
String targetName = channelPair.get(Side.CLIENT).findChannelHandlerNameForType(FMLRuntimeCodec.class);
pipeline.addAfter(targetName, "GuiHandler", new OpenGuiHandler());
pipeline.addAfter(targetName, "EntitySpawnHandler", new EntitySpawnHandler());
}
示例7: preInit
import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void preInit(FMLPreInitializationEvent event)
{
Util.logger.info("Injecting FML packet filter...");
try {
EnumMap<Side, FMLEmbeddedChannel> channelPair
= InjectionHandler.readStaticFieldOfType(FMLNetworkHandler.class, EnumMap.class);
String targetName = channelPair.get(Side.SERVER).findChannelHandlerNameForType(FMLRuntimeCodec.class);
ChannelPipeline pipeline = channelPair.get(Side.SERVER).pipeline();
pipeline.addAfter(targetName, "universalremote_OpenGuiFilter", m_openGuiFilter);
} catch (Exception e) {
Util.logger.logException("Unable to inject into FMLNetworkHandler!", e);
}
}