public class DecodingStateProtocolDecoder extends java.lang.Object implements ProtocolDecoder
ProtocolDecoder which uses a DecodingState to decode data.
Use a DecodingStateMachine as DecodingState to create
a state machine which can decode your protocol.
NOTE: This is a stateful decoder. You should create one instance per session.
| Modifier and Type | Field and Description |
|---|---|
private IoSession |
session |
private DecodingState |
state |
private java.util.Queue<IoBuffer> |
undecodedBuffers |
| Constructor and Description |
|---|
DecodingStateProtocolDecoder(DecodingState state)
Creates a new instance using the specified
DecodingState
instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
decode(IoSession session,
IoBuffer in,
ProtocolDecoderOutput out)
Decodes binary or protocol-specific content into higher-level message objects.
|
void |
dispose(IoSession session)
Releases all resources related with this decoder.
|
void |
finishDecode(IoSession session,
ProtocolDecoderOutput out)
Invoked when the specified session is closed.
|
private final DecodingState state
private final java.util.Queue<IoBuffer> undecodedBuffers
private IoSession session
public DecodingStateProtocolDecoder(DecodingState state)
DecodingState
instance.state - the DecodingState.java.lang.IllegalArgumentException - if the specified state is null.public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws java.lang.Exception
ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method with read data, and then the decoder implementation puts decoded
messages into ProtocolDecoderOutput.decode in interface ProtocolDecoderjava.lang.Exception - if the read data violated protocol specificationpublic void finishDecode(IoSession session, ProtocolDecoderOutput out) throws java.lang.Exception
ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method didn't process completely.finishDecode in interface ProtocolDecoderjava.lang.Exception - if the read data violated protocol specificationpublic void dispose(IoSession session) throws java.lang.Exception
dispose in interface ProtocolDecoderjava.lang.Exception - if failed to dispose all resources