Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
No description, website, or topics provided.
Java HTML
Branch: master
Clone or download
Cannot retrieve the latest commit at this time.
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
img
src/main
README.md
pom.xml

README.md

SseChat Sample

A simple chat room using JAX-RS 2.1 Server Sent Events (SSE)

This sample is intended to help understand how to write SSE applications that broadcast events to multiple clients. In this sample, a remote client would register (GET) with the ChatResource - this establishes an SSE connection - and then clients could send (PUT) a message. The ChatResource would then broadcast that message to all registered clients.

To run this sample, first download or clone this repo - to clone:

git clone git@github.com:OpenLiberty/sample-sse-chat.git

From inside the sample-sse-chat directory, build and start the application in Open Liberty with the following command:

mvn clean package liberty:run-server

The server will listen on port 9080 by default. You can change the port (for example, to port 9081) by adding mvn clean package liberty:run-server -DtestServerHttpPort=9081 to the end of the Maven command.

After the server has started, you should see some output like this:

At this point, you can enter the following URL into your browser:

http://localhost:9080/SseChatSample/index.html

I recommend connecting with multiple browsers, so that you can have a conversation like this one:

Note that SSEs do not work in all browsers. Consult Wikipedia for more information on browsers that support SSEs.

Press Ctrl-C from the command line to stop the server.

Please take a look at the source code that makes this possible. If you run into any problems with the sample, please let us know by opening a new issue.

Thanks!

You can’t perform that action at this time.