当前位置: 首页>>代码示例>>Java>>正文


Java ChannelHandlerContext.pipeline方法代码示例

本文整理汇总了Java中io.netty.channel.ChannelHandlerContext.pipeline方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelHandlerContext.pipeline方法的具体用法?Java ChannelHandlerContext.pipeline怎么用?Java ChannelHandlerContext.pipeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.channel.ChannelHandlerContext的用法示例。


在下文中一共展示了ChannelHandlerContext.pipeline方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: switchToBinary

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
private void switchToBinary(ChannelHandlerContext ctx) {
    ChannelPipeline p = ctx.pipeline();
    p.addLast(new DelimiterBasedFrameDecoder(maxFrameLength, Delimiters.lineDelimiter()));
    p.addLast(new StringDecoder(Charset.forName(charset)));
    p.addLast(new NetoJsonToMessageDecoder(opcodeMap));

    NetoMessageToJsonEncoder netoMessageToJsonEncoder = new NetoMessageToJsonEncoder();
    netoMessageToJsonEncoder.setOpcodeMap(opcodeMap);

    p.addLast(netoMessageToJsonEncoder);
    p.addLast(new MessageHandler(redisService));
    p.remove(this);


    // 핸들러를 다시 등록 했으므로 이벤트를 전파
    ctx.fireChannelActive();
}
 
开发者ID:veritasware,项目名称:neto,代码行数:18,代码来源:ProtocolUnificationHandler.java

示例2: encode

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的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);
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:19,代码来源:ConnectionEncoder.java

示例3: handleMessage

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的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());
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:21,代码来源:WorldLoginListener.java

示例4: enableSsl

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
private void enableSsl(ChannelHandlerContext ctx) {

        logger.info("Enabled SSL Context");

        ChannelPipeline p = ctx.pipeline();
        p.addLast("ssl", sslCtx.newHandler(ctx.alloc()));
        p.addLast("unification-ssl", new ProtocolUnificationHandler(isUnificationMode, opcodeMap, sslCtx, false, maxFrameLength, charset));
        p.remove(this);
    }
 
开发者ID:veritasware,项目名称:neto,代码行数:10,代码来源:ProtocolUnificationHandler.java

示例5: switchToHttp

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
private void switchToHttp(ChannelHandlerContext ctx) {
    ChannelPipeline p = ctx.pipeline();
    p.addLast(new HttpServerCodec());
    p.addLast(new HttpObjectAggregator(65536));
    p.addLast(new WebSocketServerCompressionHandler());
    p.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, "ws", true));
    p.addLast(new NetoJsonStringToMapWebSocketDecoder());
    p.addLast(new NetoMessageToWebsocketFrameEncoder());
    p.remove(this);

    // 핸들러를 다시 등록 했으므로 이벤트를 전파
    ctx.fireChannelActive();
}
 
开发者ID:veritasware,项目名称:neto,代码行数:14,代码来源:ProtocolUnificationHandler.java

示例6: handlerAdded

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的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);
    }
}
 
开发者ID:zhoulifu,项目名称:ss-java,代码行数:10,代码来源:ShadowsocksMessageCodec.java

示例7: channelRead0

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, NetworkMessage msg) throws Exception {
	NetworkMessageListener<NetworkMessage> listener = NetworkMessageRepository.getNetworkListener(msg);

	listener.handleMessage(ctx, msg);

	ChannelPipeline pipeline = ctx.pipeline();
	ChannelHandler handler = msg.getHandler();

	if (pipeline.context(handler) != null) {

		// flush for specific handler.
		pipeline.context(handler).flush();
	}
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:16,代码来源:NetworkMessageHandler.java

示例8: encode

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的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);
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:16,代码来源:LoginEncoder.java

示例9: encode

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的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);
}
 
开发者ID:jordanabrahambaws,项目名称:Quavo,代码行数:15,代码来源:HandshakeEncoder.java


注:本文中的io.netty.channel.ChannelHandlerContext.pipeline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。