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.TypeWebSocket message types. | 
| Constructor and Description | 
|---|
| WebSocketMessage(WebSocketMessage.Type type,
                DataBuffer payload)Constructor for a WebSocketMessage. | 
| WebSocketMessage(WebSocketMessage.Type type,
                DataBuffer payload,
                Object nativeMessage)Constructor for an inbound message with access to the underlying message. | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | equals(Object other) | 
| <T> T | getNativeMessage()Return the message from the API of the underlying WebSocket library. | 
| DataBuffer | getPayload()Return the message payload. | 
| String | getPayloadAsText()A variant of  getPayloadAsText(Charset)that usesUTF-8for 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  DataBufferwhich 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(WebSocketMessage.Type type, DataBuffer payload, @Nullable Object nativeMessage)
type - the type of WebSocket messagepayload - the message contentnativeMessage - the message from the API of the underlying WebSocket
 library, if applicable.public WebSocketMessage.Type getType()
public DataBuffer getPayload()
@Nullable public <T> T getNativeMessage()
T - the type to cast the underlying message tonullpublic 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)