Chat application built based on web socket protocol using embedded jetty.
The WebSocket protocol reference: https://www.w3.org/TR/websockets/
Embedded Jetty: https://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
- JAVA SE 11 (oracle or openjdk) installed and JAVA_HOME, PATH variables should be configured
- MAVEN >= 3.6.0 installed and M2_HOME, PATH variables are configured
- clone or download the repository
- Build the source code using "mvn clean install"
- Goto target directory in the source code location.
- open shell/cmd and run the application using "java -jar chat-ws-jar-with-dependencies.jar"
Now you can connect to the websocket server using ws://localhost:8080/chat/ url. You can use "Simple WebSocket Client" chrome or firefox plugin for simple tests. or write your own HTML+JS client.
- To stop the server either use keyboard shortcut on the cmd/shell - "ctrl+c" or give a POST request to "http://localhost:8080/shutdown?token="
{ "subscribe":"chat", "name":"..." }
{ "message":"..." }
{ "unsubscribe":"chat" }
You are welcome to modify the code as you need after clonning/downloading to your local machine.