Class AbstractWebSocketProcessor
java.lang.Object
org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor
- All Implemented Interfaces:
IWebSocketProcessor
- Direct Known Subclasses:
JavaxWebSocketProcessor
The base implementation of IWebSocketProcessor. Provides the common logic
for registering a web socket connection and broadcasting its events.
- Since:
- 6.0
-
Constructor Summary
ConstructorDescriptionAbstractWebSocketProcessor
(jakarta.servlet.http.HttpServletRequest request, WebApplication application) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
broadcastMessage
(IWebSocketMessage message) final void
broadcastMessage
(IWebSocketMessage message, IWebSocketConnection connection, boolean asynchronousPush, long timeout) Exports the Wicket thread locals and broadcasts the received message from the client to all interested components and behaviors in the page with id#pageId
protected final WebApplication
protected IKey
protected final String
void
A notification after the close of the web socket connection.protected final void
onConnect
(IWebSocketConnection connection) A helper that registers the opened connection in the application-level registry.void
A notification after a communication error.void
onMessage
(byte[] data, int offset, int length) Called when a binary message arrives from the clientvoid
Called when a text message arrives from the clientMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.wicket.protocol.ws.api.IWebSocketProcessor
onOpen, onOpen
-
Constructor Details
-
AbstractWebSocketProcessor
public AbstractWebSocketProcessor(jakarta.servlet.http.HttpServletRequest request, WebApplication application) Constructor.- Parameters:
request
- the http request that was used to create thisIWebSocketProcessor
application
- the current Wicket Application
-
-
Method Details
-
onMessage
Description copied from interface:IWebSocketProcessor
Called when a text message arrives from the client- Specified by:
onMessage
in interfaceIWebSocketProcessor
- Parameters:
message
- the text message from the client
-
onMessage
Description copied from interface:IWebSocketProcessor
Called when a binary message arrives from the client- Specified by:
onMessage
in interfaceIWebSocketProcessor
- Parameters:
data
- the binary message from the clientoffset
- the offset to read fromlength
- how much data to read
-
onConnect
A helper that registers the opened connection in the application-level registry.- Parameters:
connection
- the web socket connection to use to communicate with the client- See Also:
-
onClose
Description copied from interface:IWebSocketProcessor
A notification after the close of the web socket connection. The connection could be closed by either the client or the server- Specified by:
onClose
in interfaceIWebSocketProcessor
- Parameters:
closeCode
- The close codemessage
- the message
-
onError
Description copied from interface:IWebSocketProcessor
A notification after a communication error.- Specified by:
onError
in interfaceIWebSocketProcessor
- Parameters:
t
- The throwable for the communication problem
-
broadcastMessage
-
broadcastMessage
public final void broadcastMessage(IWebSocketMessage message, IWebSocketConnection connection, boolean asynchronousPush, long timeout) Exports the Wicket thread locals and broadcasts the received message from the client to all interested components and behaviors in the page with id#pageId
Note: ConnectedMessage and ClosedMessage messages are notification-only. I.e. whatever the components/behaviors write in the WebSocketRequestHandler will be ignored because the protocol doesn't expect response from the user.
- Parameters:
message
- the message to broadcastconnection
- theIWebSocketConnection
asynchronousPush
- whether asynchronous pus is used or nottimeout
- The time ut to use for operation (in milliseconds). A negative value means use default timeout (specified by container).
-
getApplication
-
getSessionId
-
getRegistryKey
-