本文整理汇总了Java中io.netty.channel.ChannelOutboundHandler类的典型用法代码示例。如果您正苦于以下问题:Java ChannelOutboundHandler类的具体用法?Java ChannelOutboundHandler怎么用?Java ChannelOutboundHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelOutboundHandler类属于io.netty.channel包,在下文中一共展示了ChannelOutboundHandler类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newEncoder
import io.netty.channel.ChannelOutboundHandler; //导入依赖的package包/类
@Override
public ChannelOutboundHandler newEncoder() {
return new MessageToByteEncoder<byte[]>() {
@Override
protected void encode(ChannelHandlerContext ctx, byte[] msg,
ByteBuf out) throws Exception {
out.writeBytes(msg);
}
};
}
示例2: newEncoder
import io.netty.channel.ChannelOutboundHandler; //导入依赖的package包/类
@Override
public ChannelOutboundHandler newEncoder() {
return new MessageToByteEncoder<ByteBean>() {
@Override
protected void encode(ChannelHandlerContext ctx, ByteBean msg,
ByteBuf out) throws Exception {
out.writeBytes(msg.getContent(), msg.getPosition(), msg.getLength());
}
};
}
示例3: encoder
import io.netty.channel.ChannelOutboundHandler; //导入依赖的package包/类
public ChannelOutboundHandler encoder() {
return encoder;
}
示例4: newEncoder
import io.netty.channel.ChannelOutboundHandler; //导入依赖的package包/类
@Override
public ChannelOutboundHandler newEncoder() {
return new DefaultByteArrayEncoderHandler();
}
示例5: newEncoder
import io.netty.channel.ChannelOutboundHandler; //导入依赖的package包/类
@Override
public ChannelOutboundHandler newEncoder() {
return new ChannelEncoder();
}
示例6: addHandler
import io.netty.channel.ChannelOutboundHandler; //导入依赖的package包/类
/**
* Add a {@link ChannelHandler} with {@link #addHandlerFirst} if of type of
* {@link io.netty.channel.ChannelOutboundHandler} otherwise with
* {@link #addHandlerLast}. Implementation may add more auto handling in particular
* HTTP based context will prepend an HttpContent body extractor.
* <p>
* {@code [ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]}
* <p>
* If effectively added, the handler will be safely removed when the channel is made
* inactive (pool release).
*
* @param name handler name
* @param handler handler instance
*
* @return this NettyContext
*/
default NettyContext addHandler(String name, ChannelHandler handler){
if(handler instanceof ChannelOutboundHandler){
addHandlerFirst(name, handler);
}
else {
addHandlerLast(name, handler);
}
return this;
}
示例7: newEncoder
import io.netty.channel.ChannelOutboundHandler; //导入依赖的package包/类
/**
* 创建编码器句柄
* @return
*/
public ChannelOutboundHandler newEncoder();