public class FrameDecoder extends Object implements IBaseDecoder<ByteBuffer,Frame>
Constructor and Description |
---|
FrameDecoder(boolean clientMode,
boolean allowExtensions,
long maxPayloadLen)
Constructs a Web Socket 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,
ByteBuffer data,
List<Frame> out)
Decodes data from one type to another one.
|
Class<ByteBuffer> |
getInboundType()
Returns the type of the accepted inbound objects.
|
Class<Frame> |
getOutboundType()
Returns the type of the produced outbound objects.
|
public FrameDecoder(boolean clientMode, boolean allowExtensions, long maxPayloadLen)
clientMode
- determines the mode (client/server) in which the
decoder should workallowExtensions
- determines it the decoder should allow to use the
reserved extension bitsmaxPayloadLen
- maximum length of a frame's payload data. Setting it
to an appropriate value can prevent from denial of
service attackspublic Class<ByteBuffer> getInboundType()
ICodec
getInboundType
in interface ICodec<ByteBuffer,Frame>
public Class<Frame> getOutboundType()
ICodec
getOutboundType
in interface ICodec<ByteBuffer,Frame>
public void decode(ISession session, ByteBuffer data, List<Frame> 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.
public 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<ByteBuffer,Frame>
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<ByteBuffer,Frame>
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.