Top Description Inners Fields Constructors Methods
io.netty.handler.codec.http.websocketx

public Class WebSocket08FrameDecoder

extends ByteToMessageDecoder
implements WebSocketFrameDecoder
Class Inheritance
All Implemented Interfaces
io.netty.handler.codec.http.websocketx.WebSocketFrameDecoder, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelHandler
Known Direct Subclasses
io.netty.handler.codec.http.websocketx.WebSocket13FrameDecoder, io.netty.handler.codec.http.websocketx.WebSocket07FrameDecoder
Imports
io.netty.buffer.ByteBuf, .Unpooled, io.netty.channel.ChannelFutureListener, .ChannelHandlerContext, io.netty.handler.codec.ByteToMessageDecoder, .TooLongFrameException, io.netty.util.internal.ObjectUtil, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.nio.ByteOrder, java.util.List

Decodes a web socket frame from wire protocol version 8 format. This code was forked from webbit and modified.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private final WebSocketDecoderConfig
private int
private boolean
private boolean
private int
private int
private long
private int
private static final InternalLogger
private int
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private boolean
private WebSocket08FrameDecoder.State
Inherited from io.netty.handler.codec.ByteToMessageDecoder:
COMPOSITE_CUMULATORMERGE_CUMULATOR

Constructor Summary

AccessConstructor and Description
public
WebSocket08FrameDecoder(boolean
Web socket servers must set this to true processed incoming masked payload. Client implementations must set this to false.
expectMaskedFrames
,
boolean
Flag to allow reserved extension bits to be used or not
allowExtensions
,
int
Maximum length of a frame's payload. Setting this to an appropriate value for you application helps check for denial of services attacks.
maxFramePayloadLength
)

Constructor

public
WebSocket08FrameDecoder(boolean
Web socket servers must set this to true processed incoming masked payload. Client implementations must set this to false.
expectMaskedFrames
,
boolean
Flag to allow reserved extension bits to be used or not
allowExtensions
,
int
Maximum length of a frame's payload. Setting this to an appropriate value for you application helps check for denial of services attacks.
maxFramePayloadLength
,
boolean
When set to true, frames which are not masked properly according to the standard will still be accepted.
allowMaskMismatch
)

Constructor

public
WebSocket08FrameDecoder(WebSocketDecoderConfig
Frames decoder configuration.
decoderConfig
)

Constructor

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
decode(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
,
List<Object>
the List to which decoded messages should be added
out
)

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other.
private void
private void
private void
private static int
toFrameLength(long l)

private void
unmask(ByteBuf frame)

Inherited from io.netty.handler.codec.ByteToMessageDecoder:
actualReadableBytescallDecodechannelInactivechannelReadchannelReadCompletedecodeLastdiscardSomeReadByteshandlerRemovedhandlerRemoved0internalBufferisSingleDecodesetCumulatorsetDiscardAfterReadssetSingleDecodeuserEventTriggered

Field Detail

configback to summary
private final WebSocketDecoderConfig config
fragmentedFramesCountback to summary
private int fragmentedFramesCount
frameFinalFlagback to summary
private boolean frameFinalFlag
frameMaskedback to summary
private boolean frameMasked
frameOpcodeback to summary
private int frameOpcode
framePayloadLen1back to summary
private int framePayloadLen1
framePayloadLengthback to summary
private long framePayloadLength
frameRsvback to summary
private int frameRsv
loggerback to summary
private static final InternalLogger logger
maskback to summary
private int mask
OPCODE_BINARYback to summary
private static final byte OPCODE_BINARY
OPCODE_CLOSEback to summary
private static final byte OPCODE_CLOSE
OPCODE_CONTback to summary
private static final byte OPCODE_CONT
OPCODE_PINGback to summary
private static final byte OPCODE_PING
OPCODE_PONGback to summary
private static final byte OPCODE_PONG
OPCODE_TEXTback to summary
private static final byte OPCODE_TEXT
receivedClosingHandshakeback to summary
private boolean receivedClosingHandshake
stateback to summary
private WebSocket08FrameDecoder.State state

Constructor Detail

WebSocket08FrameDecoderback to summary
public WebSocket08FrameDecoder(boolean expectMaskedFrames, boolean allowExtensions, int maxFramePayloadLength)

Constructor

Parameters
expectMaskedFrames:boolean

Web socket servers must set this to true processed incoming masked payload. Client implementations must set this to false.

allowExtensions:boolean

Flag to allow reserved extension bits to be used or not

maxFramePayloadLength:int

Maximum length of a frame's payload. Setting this to an appropriate value for you application helps check for denial of services attacks.

WebSocket08FrameDecoderback to summary
public WebSocket08FrameDecoder(boolean expectMaskedFrames, boolean allowExtensions, int maxFramePayloadLength, boolean allowMaskMismatch)

Constructor

Parameters
expectMaskedFrames:boolean

Web socket servers must set this to true processed incoming masked payload. Client implementations must set this to false.

allowExtensions:boolean

Flag to allow reserved extension bits to be used or not

maxFramePayloadLength:int

Maximum length of a frame's payload. Setting this to an appropriate value for you application helps check for denial of services attacks.

allowMaskMismatch:boolean

When set to true, frames which are not masked properly according to the standard will still be accepted.

WebSocket08FrameDecoderback to summary
public WebSocket08FrameDecoder(WebSocketDecoderConfig decoderConfig)

Constructor

Parameters
decoderConfig:WebSocketDecoderConfig

Frames decoder configuration.

Method Detail

checkCloseFrameBodyback to summary
protected void checkCloseFrameBody(ChannelHandlerContext ctx, ByteBuf buffer)
decodeback to summary
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Doc from io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:ByteBuf

the ByteBuf from which to read data

out:List<Object>

the List to which decoded messages should be added

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
protocolViolationback to summary
private void protocolViolation(ChannelHandlerContext ctx, ByteBuf in, String reason)
protocolViolationback to summary
private void protocolViolation(ChannelHandlerContext ctx, ByteBuf in, WebSocketCloseStatus status, String reason)
protocolViolationback to summary
private void protocolViolation(ChannelHandlerContext ctx, ByteBuf in, CorruptedWebSocketFrameException ex)
toFrameLengthback to summary
private static int toFrameLength(long l)
unmaskback to summary
private void unmask(ByteBuf frame)
io.netty.handler.codec.http.websocketx back to summary

pack-priv final Enum WebSocket08FrameDecoder.State

extends Enum<WebSocket08FrameDecoder.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final WebSocket08FrameDecoder.State
public static final WebSocket08FrameDecoder.State
public static final WebSocket08FrameDecoder.State
public static final WebSocket08FrameDecoder.State
public static final WebSocket08FrameDecoder.State
public static final WebSocket08FrameDecoder.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static WebSocket08FrameDecoder.State
public static WebSocket08FrameDecoder.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CORRUPTback to summary
public static final WebSocket08FrameDecoder.State CORRUPT
MASKING_KEYback to summary
public static final WebSocket08FrameDecoder.State MASKING_KEY
PAYLOADback to summary
public static final WebSocket08FrameDecoder.State PAYLOAD
READING_FIRSTback to summary
public static final WebSocket08FrameDecoder.State READING_FIRST
READING_SECONDback to summary
public static final WebSocket08FrameDecoder.State READING_SECOND
READING_SIZEback to summary
public static final WebSocket08FrameDecoder.State READING_SIZE

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static WebSocket08FrameDecoder.State valueOf(String name)
valuesback to summary
public static WebSocket08FrameDecoder.State[] values()