public class WebSocketMessage
extends java.lang.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(java.lang.Object other) |
DataBuffer |
getPayload()
Return the message payload.
|
java.lang.String |
getPayloadAsText()
A variant of
getPayloadAsText(Charset) that uses UTF-8
for decoding the raw content to text. |
java.lang.String |
getPayloadAsText(java.nio.charset.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.
|
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 java.lang.String getPayloadAsText()
getPayloadAsText(Charset) that uses UTF-8
for decoding the raw content to text.public java.lang.String getPayloadAsText(java.nio.charset.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)public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object