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

public class EslFrameDecoder extends io.netty.handler.codec.ReplayingDecoder<EslFrameDecoder.State>
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 Classes
    Modifier and Type
    Class
    Description
    protected static enum 
     

    Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder

    io.netty.handler.codec.ByteToMessageDecoder.Cumulator

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private EslMessage
     
    (package private) static final byte
    Line feed character
    private final int
     
    private boolean
     

    Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder

    COMPOSITE_CUMULATOR, MERGE_CUMULATOR
  • Constructor Summary

    Constructors
    Constructor
    Description
    EslFrameDecoder(int maxHeaderSize)
     
    EslFrameDecoder(int maxHeaderSize, boolean treatUnknownHeadersAsBody)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out)
     
    private String
    readLine(io.netty.buffer.ByteBuf buffer, int maxLineLength)
     
    private String
    readToLineFeedOrFail(io.netty.buffer.ByteBuf buffer, int maxLineLegth)
     

    Methods inherited from class io.netty.handler.codec.ReplayingDecoder

    callDecode, checkpoint, checkpoint, state, state

    Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder

    actualReadableBytes, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded
  • Field Details

    • LF

      static final byte LF
      Line feed character
      See Also:
    • maxHeaderSize

      private final int maxHeaderSize
    • currentMessage

      private EslMessage 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:
      decode in class io.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