The websocket-hello
quickstart demonstrates how to create a simple WebSocket application.
The websocket-hello
quickstart demonstrates how to create a simple WebSocket-enabled application in {productNameFull}. It consists of the following:
-
A JavaScript enabled WebSocket HTML client.
-
A WebSocket server endpoint that uses annotations to interact with the WebSocket events.
-
A
jboss-web.xml
file configured to enable WebSockets
WebSockets are a requirement of the {javaVersion} specification and are implemented in {productName} {productVersion}. They are configured in the undertow
subsystem of the server configuration file. This quickstart uses the WebSocket default settings, so it is not necessary to modify the server configuration to deploy and run this quickstart.
Note
|
This quickstart demonstrates only a few of the basic functions. A fully functional application should provide better error handling and intercept and handle additional events. |
The application will be running at the following URL: http://localhost:8080/{artifactId}/.
-
Click on the Open Connection button to create the WebSocket connection and display current status of
Open
. -
Type a name and click Say Hello to create and send the
Say hello to NAME
message. The message appears in the server log and a response is sent to the client. -
Click on the Close Connection button to close the WebSocket connection and display the current status of Closed.
-
If you attempt to send another message after closing the connection, the following message appears on the page:
WebSocket connection is not established. Please click the Open Connection button.