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
Modifier and TypeClassDescriptionstatic class
Results fromHttpEncoder
provide no additional information compared toCodec.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 TypeMethodDescriptionencode
(Buffer in, ByteBuffer out, boolean endOfInput) Encodes a message.void
encode
(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.Factory
Returns 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:Encoder
Sets the peer decoder.Some decoder implementations need to know the state of the decoder or the last decoded message.
- Specified by:
setPeerDecoder
in 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:Encoder
Returns the type of the messages encoded by this encoder.- Specified by:
encoding
in interfaceEncoder<WsFrameHeader,
WsFrameHeader> - Returns:
- the value
-
encode
Description copied from interface:Encoder
Set 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:
encode
in interfaceEncoder<WsFrameHeader,
WsFrameHeader> - Parameters:
messageHeader
- the message header
-
encode
Description copied from interface:Encoder
Encodes a message.First encodes the message header set by
Encoder.encode(MessageHeader)
and then (optionally) adds payload data from in.- Specified by:
encode
in 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:Encoder
Returns the last message (header) encoded.- Specified by:
header
in interfaceEncoder<WsFrameHeader,
WsFrameHeader> - Returns:
- the result
-