Class EslFrameDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.ReplayingDecoder<EslFrameDecoder.State>
com.bytedesk.call.esl.client.transport.message.EslFrameDecoder
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
Decoder used by the IO processing pipeline. Client consumers should never need to use
this class.
Follows the following decode algorithm (from FreeSWITCH wiki)
Look for \n\n in your receive buffer
Examine data for existence of Content-Length
If NOT present, process event and remove from receive buffer
IF present, Shift buffer to remove 'header'
Evaluate content-length value
Loop until receive buffer size is >= Content-length
Extract content-length bytes from buffer and process
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate EslMessage(package private) static final byteLine feed characterprivate final intprivate booleanFields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsConstructorDescriptionEslFrameDecoder(int maxHeaderSize) EslFrameDecoder(int maxHeaderSize, boolean treatUnknownHeadersAsBody) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddecode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out) private StringreadLine(io.netty.buffer.ByteBuf buffer, int maxLineLength) private StringreadToLineFeedOrFail(io.netty.buffer.ByteBuf buffer, int maxLineLegth) Methods inherited from class io.netty.handler.codec.ReplayingDecoder
callDecode, checkpoint, checkpoint, state, stateMethods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded
-
Field Details
-
LF
static final byte LFLine feed character- See Also:
-
maxHeaderSize
private final int maxHeaderSize -
currentMessage
-
treatUnknownHeadersAsBody
private boolean treatUnknownHeadersAsBody
-
-
Constructor Details
-
EslFrameDecoder
public EslFrameDecoder(int maxHeaderSize) -
EslFrameDecoder
public EslFrameDecoder(int maxHeaderSize, boolean treatUnknownHeadersAsBody)
-
-
Method Details
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out) throws Exception - Specified by:
decodein classio.netty.handler.codec.ByteToMessageDecoder- Throws:
Exception
-
readToLineFeedOrFail
private String readToLineFeedOrFail(io.netty.buffer.ByteBuf buffer, int maxLineLegth) throws io.netty.handler.codec.TooLongFrameException - Throws:
io.netty.handler.codec.TooLongFrameException
-
readLine
private String readLine(io.netty.buffer.ByteBuf buffer, int maxLineLength) throws io.netty.handler.codec.TooLongFrameException - Throws:
io.netty.handler.codec.TooLongFrameException
-