Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (64 sloc) 3.77 KB

websocket-hello: A simple WebSocket application

The websocket-hello quickstart demonstrates how to create a simple WebSocket application.

What is it?

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.

Access the Application

The application will be running at the following URL: http://localhost:8080/{artifactId}/.

  1. Click on the Open Connection button to create the WebSocket connection and display current status of Open.

  2. 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.

  3. Click on the Close Connection button to close the WebSocket connection and display the current status of Closed.

  4. 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.
You can’t perform that action at this time.