T - public abstract class ServerJSONWebSocketAdapter<T>
extends org.eclipse.jetty.websocket.api.WebSocketAdapter
| Constructor and Description |
|---|
ServerJSONWebSocketAdapter() |
| Modifier and Type | Method and Description |
|---|---|
protected <C> C |
convert(Object object,
Class<C> targetClass)
convert object into another class using the JSON mapper
|
protected abstract Class<T> |
getObjectType() |
protected void |
onWebSocketEmptyMessage()
called if received message was null or empty
|
protected void |
onWebSocketInvalidMessage(String message)
called if message was invalid and not parsable into the given type
|
protected abstract void |
onWebSocketObject(T message)
called on incoming messages that were parsed into the given object class
|
void |
onWebSocketText(String message) |
protected void |
sendObjectToSocket(Object objectToSend)
send object to client and serialize it using JSON
uses a generic callback that prints errors to the log |
protected void |
sendObjectToSocket(Object objectToSend,
org.eclipse.jetty.websocket.api.WriteCallback cb)
send object to client and serialize it using JSON
|
public final void onWebSocketText(String message)
onWebSocketText in interface org.eclipse.jetty.websocket.api.WebSocketListeneronWebSocketText in class org.eclipse.jetty.websocket.api.WebSocketAdapterprotected void onWebSocketEmptyMessage()
protected void onWebSocketInvalidMessage(String message)
message - the raw message received on the socketprotected abstract Class<T> getObjectType()
protected abstract void onWebSocketObject(T message)
message - the parsed an converted messageprotected <C> C convert(Object object, Class<C> targetClass)
C - the generic target typeobject - the object to converttargetClass - the class of the target objectIllegalArgumentException - if conversion failsprotected final void sendObjectToSocket(Object objectToSend)
objectToSend - the object to sendprotected final void sendObjectToSocket(Object objectToSend, org.eclipse.jetty.websocket.api.WriteCallback cb)
objectToSend - the object to sendcb - the callback after sending the messageCopyright © 2015–2018 Taimos GmbH. All rights reserved.