public class WebSocketMessage extends Object
See static factory methods in WebSocketSession
for creating messages
with the DataBufferFactory
for the session.
Modifier and Type | Class and Description |
---|---|
static class |
WebSocketMessage.Type
WebSocket message types.
|
Constructor and Description |
---|
WebSocketMessage(WebSocketMessage.Type type,
DataBuffer payload)
Constructor for a WebSocketMessage.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
DataBuffer |
getPayload()
Return the message payload.
|
String |
getPayloadAsText()
A variant of
getPayloadAsText(Charset) that uses UTF-8
for decoding the raw content to text. |
String |
getPayloadAsText(Charset charset)
A shortcut for decoding the raw content of the message to text with the
given character encoding.
|
WebSocketMessage.Type |
getType()
Return the message type (text, binary, etc).
|
int |
hashCode() |
void |
release()
Release the payload
DataBuffer which is useful on runtimes
(e.g. |
WebSocketMessage |
retain()
Retain the data buffer for the message payload, which is useful on
runtimes (e.g.
|
String |
toString() |
public WebSocketMessage(WebSocketMessage.Type type, DataBuffer payload)
See static factory methods in WebSocketSession
or alternatively
use WebSocketSession.bufferFactory()
to create the payload and
then invoke this constructor.
public WebSocketMessage.Type getType()
public DataBuffer getPayload()
public String getPayloadAsText()
getPayloadAsText(Charset)
that uses UTF-8
for decoding the raw content to text.public String getPayloadAsText(Charset charset)
charset
- the character encodingpublic WebSocketMessage retain()
DataBuffer payload = message.getPayload(); DataBufferUtils.retain(payload);
DataBufferUtils.retain(DataBuffer)
public void release()
DataBuffer
which is useful on runtimes
(e.g. Netty) with pooled buffers such as Netty. A shortcut for:
DataBuffer payload = message.getPayload(); DataBufferUtils.release(payload);
DataBufferUtils.release(DataBuffer)