Class WebSocketBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.protocol.ws.api.BaseWebSocketBehavior
-
- org.apache.wicket.protocol.ws.api.WebSocketBehavior
-
- All Implemented Interfaces:
Serializable
,IComponentAwareEventSink
,IComponentAwareHeaderContributor
,IClusterable
public abstract class WebSocketBehavior extends BaseWebSocketBehavior
A behavior that provides optional callbacks for the WebSocket messages (connect, message, close)- Since:
- 6.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WebSocketBehavior()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
onAbort(AbortedMessage message)
A callback method called when the server has aborted the connectionprotected void
onClose(ClosedMessage message)
A callback method called when a WebSocket client has closed the connection to the endpoint handled by this WebSocketBehaviorprotected void
onConnect(ConnectedMessage message)
A callback method called when a WebSocket client has connected to the endpoint handled by this WebSocketBehaviorprotected void
onError(WebSocketRequestHandler handler, ErrorMessage message)
A callback method called when there is a communication errorvoid
onEvent(Component component, IEvent<?> event)
Called to notify the behavior about any events sent to the componentprotected void
onMessage(WebSocketRequestHandler handler, BinaryMessage binaryMessage)
A callback method called when there is a binary message sent by the clientprotected void
onMessage(WebSocketRequestHandler handler, TextMessage message)
A callback method called when there is a text message sent by the clientprotected void
onPush(WebSocketRequestHandler handler, IWebSocketPushMessage message)
A callback method called when there is a message pushed/broadcasted by the server, e.g.-
Methods inherited from class org.apache.wicket.protocol.ws.api.BaseWebSocketBehavior
getBaseUrl, getContext, getContextPath, getFilterPrefix, getPort, getSecurePort, getSessionId, getStatelessHint, getWebSocketSetupScript, renderHead
-
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, bind, canCallListener, detach, isEnabled, isTemporary, onAttribute, onComponentTag, onConfigure, onException, onRemove, onTag, unbind
-
-
-
-
Constructor Detail
-
WebSocketBehavior
public WebSocketBehavior()
-
-
Method Detail
-
onEvent
public void onEvent(Component component, IEvent<?> event)
Description copied from class:Behavior
Called to notify the behavior about any events sent to the component- Specified by:
onEvent
in interfaceIComponentAwareEventSink
- Overrides:
onEvent
in classBehavior
- Parameters:
component
- component that owns this sink. For example, if the implementation of this interface is aBehavior
then component parameter will contain the component to which the behavior is attached.- See Also:
IComponentAwareEventSink.onEvent(org.apache.wicket.Component, org.apache.wicket.event.IEvent)
-
onPush
protected void onPush(WebSocketRequestHandler handler, IWebSocketPushMessage message)
A callback method called when there is a message pushed/broadcasted by the server, e.g. pushed by a backend service- Parameters:
handler
- The request handler that can be used to send messages to the clientmessage
- The message pushed/broadcasted by the server
-
onConnect
protected void onConnect(ConnectedMessage message)
A callback method called when a WebSocket client has connected to the endpoint handled by this WebSocketBehavior- Parameters:
message
- the connect message with the info about the client
-
onClose
protected void onClose(ClosedMessage message)
A callback method called when a WebSocket client has closed the connection to the endpoint handled by this WebSocketBehavior- Parameters:
message
- the close message with the info about the client
-
onError
protected void onError(WebSocketRequestHandler handler, ErrorMessage message)
A callback method called when there is a communication error- Parameters:
handler
- The request handler that can be used to send messages to the clientmessage
- The error message that that brings information about the communication error
-
onAbort
protected void onAbort(AbortedMessage message)
A callback method called when the server has aborted the connection- Parameters:
message
- the aborted message with the info about the client
-
onMessage
protected void onMessage(WebSocketRequestHandler handler, TextMessage message)
A callback method called when there is a text message sent by the client- Parameters:
handler
- The request handler that can be used to send messages back to the clientmessage
- The text message sent by the client
-
onMessage
protected void onMessage(WebSocketRequestHandler handler, BinaryMessage binaryMessage)
A callback method called when there is a binary message sent by the client- Parameters:
handler
- The request handler that can be used to send messages back to the clientbinaryMessage
- The binary message sent by the client
-
-