public class HandshakeDecoder extends Object implements IDecoder<byte[],HandshakeFrame>, IBaseDecoder<byte[],HandshakeFrame>
Constructor and Description |
---|
HandshakeDecoder(boolean clientMode)
Constructs a Web Socket handshake decoder with the default maximum length
(65536) of a handshake frame and the default maximum number (50) of lines of
a handshake frame to be decoded in a single pass.
|
HandshakeDecoder(boolean clientMode,
int maxLength)
Constructs a Web Socket handshake decoder with the default maximum number
(50) of lines of a handshake frame to be decoded in a single pass.
|
HandshakeDecoder(boolean clientMode,
int maxLength,
int maxLinesInChunk)
Constructs a Web Socket handshake decoder.
|
Modifier and Type | Method and Description |
---|---|
int |
available(ISession session,
byte[] buffer,
int off,
int len)
Determines how many bytes should be read from the input buffer to create
the byte array that will be then passed to the
IDecoder.decode(org.snf4j.core.session.ISession, I, java.util.List<O>)
method. |
int |
available(ISession session,
ByteBuffer buffer,
boolean flipped)
Determines how many bytes should be read from the input buffer to create
the byte array that will be then passed to the
IDecoder.decode(org.snf4j.core.session.ISession, I, java.util.List<O>) method. |
void |
decode(ISession session,
byte[] data,
List<HandshakeFrame> out)
Decodes data from one type to another one.
|
Class<byte[]> |
getInboundType()
Returns the type of the accepted inbound objects.
|
Class<HandshakeFrame> |
getOutboundType()
Returns the type of the produced outbound objects.
|
public HandshakeDecoder(boolean clientMode, int maxLength, int maxLinesInChunk)
clientMode
- determines the mode (client/server) in which the
decoder should workmaxLength
- maximum length of a handshake frame. Setting it to an
appropriate value can prevent from denial of service
attacksmaxLinesInChunk
- maximum number of lines of a Web Socket handshake
frame to be decoded in a single pass. Setting it to an
appropriate value can improve performance of decoding
frames with big number of lines.public HandshakeDecoder(boolean clientMode, int maxLength)
clientMode
- determines the mode (client/server) in which the decoder
should workmaxLength
- maximum length of a handshake frame. Setting it to an
appropriate value can prevent from denial of service
attackspublic HandshakeDecoder(boolean clientMode)
clientMode
- determines the mode (client/server) in which the decoder
should workpublic Class<byte[]> getInboundType()
ICodec
getInboundType
in interface ICodec<byte[],HandshakeFrame>
public Class<HandshakeFrame> getOutboundType()
ICodec
getOutboundType
in interface ICodec<byte[],HandshakeFrame>
public void decode(ISession session, byte[] data, List<HandshakeFrame> out) throws Exception
IDecoder
Decoders that do not produce an output (i.e. the O parameter is
Void
) cannot change the object passed as the data
argument. They should not also store it for future use as its state can
be changed.
The above limitations regarding the data
argument do not apply to
decoders that produce an output.
decode
in interface IDecoder<byte[],HandshakeFrame>
session
- the ISession
which the passed data belongs todata
- the data to decode to another oneout
- the List
to which the decoded data should be added, or
null
if O is Void
Exception
- is thrown, if an error occurpublic int available(ISession session, ByteBuffer buffer, boolean flipped)
IBaseDecoder
IDecoder.decode(org.snf4j.core.session.ISession, I, java.util.List<O>)
method.
This method is called only if the input buffer is not backed by an array (i.e. a direct byte buffer allocator is used to create session's internal buffers).
The inner state of the passed buffer cannot be changed by this method.
available
in interface IBaseDecoder<byte[],HandshakeFrame>
session
- the ISession
which the buffer belongs tobuffer
- the input buffer.flipped
- specifies the current mode of the bufferpublic int available(ISession session, byte[] buffer, int off, int len)
IBaseDecoder
IDecoder.decode(org.snf4j.core.session.ISession, I, java.util.List<O>)
method.
This method is called only if the input buffer is backed by an array. (i.e. a heap byte buffer allocator is used to create session's internal buffers).
The content of the passed buffer cannot be changed by this method.
available
in interface IBaseDecoder<byte[],HandshakeFrame>
session
- the ISession
which the buffer belongs tobuffer
- the array that backs the input buffer.off
- the offset of the arraylen
- the number of the bytes in the arrayCopyright © 2017–2022 SNF4J.ORG. All rights reserved.