Class WsDecoder
- All Implemented Interfaces:
Codec
,Decoder<WsFrameHeader,
WsFrameHeader>
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Results fromWsDecoder
add no additional information toDecoder.Result
.Nested classes/interfaces inherited from class org.jdrupes.httpcodec.protocols.websocket.WsCodec
WsCodec.ClosingState
Nested classes/interfaces inherited from interface org.jdrupes.httpcodec.Codec
Codec.ProtocolSwitchResult
-
Field Summary
-
Constructor Summary
-
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.Factory
Returns 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:Decoder
Sets the peer encoder.Some decoders need to know the state of the encoder or the last encoded message.
- Specified by:
setPeerEncoder
in 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:Decoder
Returns the type of the messages decoded by this decoder.- Specified by:
decoding
in interfaceDecoder<WsFrameHeader,
WsFrameHeader> - Returns:
- the value
-
header
Description copied from interface:Decoder
Returns the last message (header) received.If a header is completed during a
Decoder.decode(ByteBuffer, Buffer, boolean)
invocation, the result’sDecoder.Result.isHeaderCompleted()
istrue
and the header can be retrieved using this method. It remains available untildecode
is invoked for a new message (i.e. is invoked again after returning a result withCodec.Result.isUnderflow()
beingfalse
.- Specified by:
header
in interfaceDecoder<WsFrameHeader,
WsFrameHeader> - Returns:
- the result
-
decode
public Decoder.Result<WsFrameHeader> decode(ByteBuffer in, Buffer out, boolean endOfInput) throws ProtocolException Description copied from interface:Decoder
Decodes the next chunk of data.This method will never leave remaining data in the
in
buffer unless a header has been decoded completely and/or theout
buffer is full. In either case, decoding will therefore continue when the method is invoked again with the samein
buffer and another (or emptied)out
buffer. It is never necessary (though possible) to add data to an existingin
buffer.- Specified by:
decode
in 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
-