Class WsEncoder
java.lang.Object
org.jdrupes.httpcodec.protocols.websocket.WsCodec
org.jdrupes.httpcodec.protocols.websocket.WsEncoder
- All Implemented Interfaces:
Codec,Encoder<WsFrameHeader,WsFrameHeader>
The Websocket encoder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResults fromHttpEncoderprovide no additional information compared toCodec.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 TypeMethodDescriptionencode(Buffer in, ByteBuffer out, boolean endOfInput) Encodes a message.voidencode(WsFrameHeader messageHeader) Set the header of the message that is to be encoded.encoding()Returns the type of the messages encoded by this encoder.header()Returns the last message (header) encoded.protected WsEncoder.Result.FactoryReturns the result factory for this codec.setPeerDecoder(Decoder<WsFrameHeader, WsFrameHeader> decoder) Sets the peer decoder.Methods inherited from class org.jdrupes.httpcodec.protocols.websocket.WsCodec
closingState, linkClosingState, setClosingState
-
Constructor Details
-
WsEncoder
Creates new encoder.- Parameters:
mask- set if the data is to be masked (client)
-
-
Method Details
-
setPeerDecoder
public Encoder<WsFrameHeader,WsFrameHeader> setPeerDecoder(Decoder<WsFrameHeader, WsFrameHeader> decoder) Description copied from interface:EncoderSets the peer decoder.Some decoder implementations need to know the state of the decoder or the last decoded message.
- Specified by:
setPeerDecoderin interfaceEncoder<WsFrameHeader,WsFrameHeader> - Parameters:
decoder- the decoder- Returns:
- the encoder
-
resultFactory
Returns the result factory for this codec.- Returns:
- the factory
-
encoding
Description copied from interface:EncoderReturns the type of the messages encoded by this encoder.- Specified by:
encodingin interfaceEncoder<WsFrameHeader,WsFrameHeader> - Returns:
- the value
-
encode
Description copied from interface:EncoderSet the header of the message that is to be encoded.Must be invoked before the first invocation to any encode method for a given message.
- Specified by:
encodein interfaceEncoder<WsFrameHeader,WsFrameHeader> - Parameters:
messageHeader- the message header
-
encode
Description copied from interface:EncoderEncodes a message.First encodes the message header set by
Encoder.encode(MessageHeader)and then (optionally) adds payload data from in.- Specified by:
encodein interfaceEncoder<WsFrameHeader,WsFrameHeader> - Parameters:
in- the body dataout- the buffer to which data is writtenendOfInput- 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
-
header
Description copied from interface:EncoderReturns the last message (header) encoded.- Specified by:
headerin interfaceEncoder<WsFrameHeader,WsFrameHeader> - Returns:
- the result
-