Class WsDecoder
- All Implemented Interfaces:
Codec,Decoder<WsFrameHeader,WsFrameHeader>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResults fromWsDecoderadd no additional information toDecoder.Result.Nested classes/interfaces inherited from class org.jdrupes.httpcodec.protocols.websocket.WsCodec
WsCodec.ClosingStateNested classes/interfaces inherited from interface org.jdrupes.httpcodec.Codec
Codec.ProtocolSwitchResult -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecode(ByteBuffer in, Buffer out, boolean endOfInput) Decodes the next chunk of data.decoding()Returns the type of the messages decoded by this decoder.header()Returns the last message (header) received.protected WsDecoder.Result.FactoryReturns the result factory for this codec.setPeerEncoder(Encoder<WsFrameHeader, WsFrameHeader> encoder) Sets the peer encoder.Methods inherited from class org.jdrupes.httpcodec.protocols.websocket.WsCodec
closingState, linkClosingState, setClosingState
-
Constructor Details
-
WsDecoder
public WsDecoder()
-
-
Method Details
-
setPeerEncoder
public Decoder<WsFrameHeader,WsFrameHeader> setPeerEncoder(Encoder<WsFrameHeader, WsFrameHeader> encoder) Description copied from interface:DecoderSets the peer encoder.Some decoders need to know the state of the encoder or the last encoded message.
- Specified by:
setPeerEncoderin interfaceDecoder<WsFrameHeader,WsFrameHeader> - Parameters:
encoder- the encoder- Returns:
- the decoder
-
resultFactory
Returns the result factory for this codec.- Returns:
- the factory
-
decoding
Description copied from interface:DecoderReturns the type of the messages decoded by this decoder.- Specified by:
decodingin interfaceDecoder<WsFrameHeader,WsFrameHeader> - Returns:
- the value
-
header
Description copied from interface:DecoderReturns the last message (header) received.If a header is completed during a
Decoder.decode(ByteBuffer, Buffer, boolean)invocation, the result’sDecoder.Result.isHeaderCompleted()istrueand the header can be retrieved using this method. It remains available untildecodeis invoked for a new message (i.e. is invoked again after returning a result withCodec.Result.isUnderflow()beingfalse.- Specified by:
headerin interfaceDecoder<WsFrameHeader,WsFrameHeader> - Returns:
- the result
-
decode
public Decoder.Result<WsFrameHeader> decode(ByteBuffer in, Buffer out, boolean endOfInput) throws ProtocolException Description copied from interface:DecoderDecodes the next chunk of data.This method will never leave remaining data in the
inbuffer unless a header has been decoded completely and/or theoutbuffer is full. In either case, decoding will therefore continue when the method is invoked again with the sameinbuffer and another (or emptied)outbuffer. It is never necessary (though possible) to add data to an existinginbuffer.- Specified by:
decodein interfaceDecoder<WsFrameHeader,WsFrameHeader> - Parameters:
in- holds the data to be decodedout- gets the body data (if any) written to itendOfInput- true if there is no input left beyond the data currently in the in buffer (indicates end of body or no body at all)- Returns:
- the result
- Throws:
ProtocolException- if the message violates the HTTP
-