Class WebSocketRequestHandler
- java.lang.Object
-
- org.apache.wicket.core.request.handler.AbstractPartialPageRequestHandler
-
- org.apache.wicket.protocol.ws.api.WebSocketRequestHandler
-
- All Implemented Interfaces:
IPageClassRequestHandler
,IPageRequestHandler
,IPartialPageRequestHandler
,IWebSocketRequestHandler
,ILoggableRequestHandler
,IRequestHandler
public class WebSocketRequestHandler extends AbstractPartialPageRequestHandler implements IWebSocketRequestHandler
A handler of WebSocket requests.- Since:
- 6.0
-
-
Constructor Summary
Constructors Constructor Description WebSocketRequestHandler(Component component, IWebSocketConnection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
detach(IRequestCycle requestCycle)
This method is called at the end of a request cycle to indicate that processing is done and that cleaning up of the subject(s) of this target may be done.Collection<? extends Component>
getComponents()
Returns an unmodifiable collection of all components added to this targetILogData
getLogData()
Returns the collected log data for this request handler and should never throw an exception.protected PartialPageUpdate
getUpdate()
void
push(byte[] message, int offset, int length)
Pushes a binary message to the client.void
push(CharSequence message)
Pushes a text message to the client.Future<Void>
pushAsync(byte[] message, int offset, int length)
Pushes a binary message to the client.Future<Void>
pushAsync(byte[] message, int offset, int length, long timeout)
Pushes a binary message to the client.Future<Void>
pushAsync(CharSequence message)
Pushes a text message to the client in an asynchronous way.Future<Void>
pushAsync(CharSequence message, long timeout)
Pushes a text message to the client in an asynchronous way.void
respond(IRequestCycle requestCycle)
Generates a response.protected boolean
shouldPushWhenEmpty()
-
Methods inherited from class org.apache.wicket.core.request.handler.AbstractPartialPageRequestHandler
add, add, addChildren, appendJavaScript, focusComponent, getHeaderResponse, getPage, getPageClass, getPageId, getPageParameters, getRenderCount, isPageInstanceCreated, prependJavaScript
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.core.request.handler.IPageClassRequestHandler
getPageClass, getPageParameters
-
Methods inherited from interface org.apache.wicket.core.request.handler.IPageRequestHandler
getPage, getPageId, getRenderCount, isPageInstanceCreated
-
Methods inherited from interface org.apache.wicket.core.request.handler.IPartialPageRequestHandler
add, add, addChildren, appendJavaScript, focusComponent, getHeaderResponse, prependJavaScript
-
-
-
-
Constructor Detail
-
WebSocketRequestHandler
public WebSocketRequestHandler(Component component, IWebSocketConnection connection)
-
-
Method Detail
-
push
public void push(CharSequence message)
Description copied from interface:IWebSocketRequestHandler
Pushes a text message to the client.- Specified by:
push
in interfaceIWebSocketRequestHandler
- Parameters:
message
- the text message to push to the client if the web socket connection is open
-
pushAsync
public Future<Void> pushAsync(CharSequence message, long timeout)
Description copied from interface:IWebSocketRequestHandler
Pushes a text message to the client in an asynchronous way.- Specified by:
pushAsync
in interfaceIWebSocketRequestHandler
- Parameters:
message
- the text message to push to the client if the web socket connection is opentimeout
- the timeout for operation- Returns:
- a
Future
representing the send operation. Or null if connection is closed.
-
pushAsync
public Future<Void> pushAsync(CharSequence message)
Description copied from interface:IWebSocketRequestHandler
Pushes a text message to the client in an asynchronous way.- Specified by:
pushAsync
in interfaceIWebSocketRequestHandler
- Parameters:
message
- the text message to push to the client if the web socket connection is open- Returns:
- a
Future
representing the send operation. Or null if connection is closed.
-
push
public void push(byte[] message, int offset, int length)
Description copied from interface:IWebSocketRequestHandler
Pushes a binary message to the client.- Specified by:
push
in interfaceIWebSocketRequestHandler
- Parameters:
message
- the binary message to push to the client if the web socket connection is openoffset
- the offset to start to read from the messagelength
- how many bytes to read from the message
-
pushAsync
public Future<Void> pushAsync(byte[] message, int offset, int length)
Description copied from interface:IWebSocketRequestHandler
Pushes a binary message to the client.- Specified by:
pushAsync
in interfaceIWebSocketRequestHandler
- Parameters:
message
- the binary message to push to the client if the web socket connection is openoffset
- the offset to start to read from the messagelength
- how many bytes to read from the message- Returns:
- a
Future
representing the send operation. Or null if connection is closed.
-
pushAsync
public Future<Void> pushAsync(byte[] message, int offset, int length, long timeout)
Description copied from interface:IWebSocketRequestHandler
Pushes a binary message to the client.- Specified by:
pushAsync
in interfaceIWebSocketRequestHandler
- Parameters:
message
- the binary message to push to the client if the web socket connection is openoffset
- the offset to start to read from the messagelength
- how many bytes to read from the messagetimeout
- the timeout for operation- Returns:
- a
Future
representing the send operation. Or null if connection is closed.
-
shouldPushWhenEmpty
protected boolean shouldPushWhenEmpty()
- Returns:
- if
true
then EMPTY partial updates will se send. Iffalse
then EMPTY partial updates will be skipped. A possible use case is: a page receives and a push event but no one is listening to it, and nothing is added toWebSocketRequestHandler
thus no real push to client is needed. For compatibilities this is set to true. Thus EMPTY updates are sent by default.
-
getUpdate
protected PartialPageUpdate getUpdate()
- Specified by:
getUpdate
in classAbstractPartialPageRequestHandler
-
getComponents
public Collection<? extends Component> getComponents()
Description copied from interface:IPartialPageRequestHandler
Returns an unmodifiable collection of all components added to this target- Specified by:
getComponents
in interfaceIPartialPageRequestHandler
- Returns:
- unmodifiable collection of all components added to this target
-
getLogData
public ILogData getLogData()
Description copied from interface:ILoggableRequestHandler
Returns the collected log data for this request handler and should never throw an exception. This method is never called before the request handler is detached.- Specified by:
getLogData
in interfaceILoggableRequestHandler
- Returns:
- The collected log data.
-
respond
public void respond(IRequestCycle requestCycle)
Description copied from interface:IRequestHandler
Generates a response.- Specified by:
respond
in interfaceIRequestHandler
- Parameters:
requestCycle
- the current request cycle
-
detach
public void detach(IRequestCycle requestCycle)
Description copied from interface:IRequestHandler
This method is called at the end of a request cycle to indicate that processing is done and that cleaning up of the subject(s) of this target may be done.- Specified by:
detach
in interfaceIRequestHandler
- Parameters:
requestCycle
- the current request cycle
-
-