本文整理匯總了Java中io.netty.channel.ChannelPipeline.replace方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelPipeline.replace方法的具體用法?Java ChannelPipeline.replace怎麽用?Java ChannelPipeline.replace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.channel.ChannelPipeline
的用法示例。
在下文中一共展示了ChannelPipeline.replace方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
示例4: 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);
}