@ChannelHandler.Sharable public class Base64Decoder extends MessageToMessageDecoder<ByteBuf>
ByteBuf
或US-ASCII String
为ByteBuf
。
请注意,如果您正在使用基于流的传输(如TCP / IP),则必须使用此解码器ByteToMessageDecoder
,如DelimiterBasedFrameDecoder
。
TCP / IP的典型解码器设置为:
ChannelPipeline
pipeline = ...;
// Decoders
pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder
(80, Delimiters.nulDelimiter()
));
pipeline.addLast("base64Decoder", new Base64Decoder
());
// Encoder
pipeline.addLast("base64Encoder", new Base64Encoder
());
ChannelHandler.Sharable
Constructor and Description |
---|
Base64Decoder() |
Base64Decoder(Base64Dialect dialect) |
Modifier and Type | Method and Description |
---|---|
protected void |
decode(ChannelHandlerContext ctx, ByteBuf msg, java.util.List<java.lang.Object> out)
从一条消息解码到另一条消息。
|
acceptInboundMessage, channelRead
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded, handlerRemoved
public Base64Decoder()
public Base64Decoder(Base64Dialect dialect)
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, java.util.List<java.lang.Object> out) throws java.lang.Exception
MessageToMessageDecoder
decode
在课堂上
MessageToMessageDecoder<ByteBuf>
ctx
- 这MessageToMessageDecoder
所属的ChannelHandlerContext
msg
- 解码到另一个的消息
out
- 应该添加解码消息的
List
java.lang.Exception
- 发生错误时抛出
Copyright © 2008–2018 The Netty Project. All rights reserved.