Class WebSocketTester
java.lang.Object
org.apache.wicket.protocol.ws.tester.WebSocketTester
A helper class to test WebSocket related operations.
- Since:
- 6.0
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketTester
(WicketTester wicketTester, String resourceName) Constructor.WebSocketTester
(WicketTester wicketTester, Page page) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
broadcast
(Application application, String sessionId, IKey key, IWebSocketPushMessage message) Broadcasts/pushes a message to specific web socket connectionvoid
broadcastAll
(Application application, IWebSocketPushMessage message) Broadcasts/pushes a message to all active web socket connectionsvoid
destroy()
protected void
onOutMessage
(byte[] message, int offset, int length) A callback method which may be overritten to receive messages pushed by the serverprotected void
onOutMessage
(String message) A callback method which may be overritten to receive messages pushed by the servervoid
sendMessage
(byte[] message, int offset, int length) Sends a binary message from the client (a test case) to the servervoid
sendMessage
(String message) Sends a text message from the client (a test case) to the server
-
Constructor Details
-
WebSocketTester
Constructor. Prepares a WebSocketConnection that will be used to send messages from the client (the test case) to the server.- Parameters:
page
- the page that may have registeredWebSocketBehavior
-
WebSocketTester
Constructor. Prepares a WebSockConnection that will be used to send messages from the client (the test case) to the server.- Parameters:
resourceName
- the name of the shared WebSocketResource that will handle the web socket messages
-
-
Method Details
-
sendMessage
Sends a text message from the client (a test case) to the server- Parameters:
message
- the text message to send to the server
-
sendMessage
Sends a binary message from the client (a test case) to the server- Parameters:
message
- the binary message to send to the serveroffset
- the offset of the binary message to start to read fromlength
- the length of bytes to read from the binary message
-
broadcast
public void broadcast(Application application, String sessionId, IKey key, IWebSocketPushMessage message) Broadcasts/pushes a message to specific web socket connection- Parameters:
application
- The application where the web socket connection is registeredsessionId
- The id of the http session with which the web socket connection is registeredkey
- The key with which the web socket connection is registeredmessage
- The message to broadcast/push
-
broadcastAll
Broadcasts/pushes a message to all active web socket connections- Parameters:
application
- The application where the web socket connection is registeredmessage
- The message to broadcast/push
-
destroy
-
onOutMessage
A callback method which may be overritten to receive messages pushed by the server- Parameters:
message
- the pushed text message from the server
-
onOutMessage
A callback method which may be overritten to receive messages pushed by the server- Parameters:
message
- the pushed binary message from the serveroffset
- the offset of the binary message to start to read fromlength
- the length of bytes to read from the binary message
-