Skip to content

krisnaajiep/springboot-broadcast-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Broadcast Server

Current Version Framework WebSocket

A simple broadcast server that sends messages to all connected clients in real-time using WebSocket and STOMP.

Table of Contents

General Information

This project is a broadcast server built using Spring Boot and WebSocket with the STOMP protocol. It is packaged as a single executable JAR that can run in two modes: as a server that listens for incoming client connections, or as a client that connects to the server and sends messages. Any message sent by a client is broadcast to all other connected clients in real-time.

Technologies Used

  • Java 21.0.11
  • Spring Boot 4.0.6
  • Spring WebSocket (STOMP)

Features

  • Start a WebSocket broadcast server.
  • Connect to the server as a client.
  • Broadcast messages to all connected clients in real-time.
  • Handle multiple simultaneous client connections.
  • Graceful handling of client connect and disconnect events.

Setup

To run this project locally, you'll need Java 21 or higher.

  1. Clone the repository:

    git clone https://github.com/krisnaajiep/springboot-broadcast-server.git
  2. Navigate to the project directory:

    cd springboot-broadcast-server
  3. Build the project using Maven:

    mvn clean package -DskipTests

Usage

The application is packaged as a single JAR that runs in two modes depending on the argument passed.

Start the Server

Run the JAR with the start argument to start the broadcast server:

java -jar target/springboot-broadcast-server-1.0.0.jar start

The server will start and listen for incoming WebSocket connections:

Broadcast server starting on port 8080

Connect as a Client

Open a new terminal and run the JAR with the connect argument to connect as a client:

java -jar target/springboot-broadcast-server-1.0.0.jar connect

You will be prompted to enter your name, then connected to the server:

Connecting to ws://localhost:8080/broadcast-server
Enter your name: Client
Welcome to the broadcast server Client!

Write something to send your message:

Hello everyone!
(You)[2026-06-09 10:00:00]: Hello everyone!

Any message you send will be broadcast to all connected clients. Messages from other clients will appear as:

(Other)[2026-06-09 10:00:05]: Hello from other client!

To disconnect, press Ctrl+C.

Connecting Multiple Clients

Open as many terminals as needed and run the connect command in each one to simulate multiple clients broadcasting to each other.

Project Status

Project is: complete.

CI

Acknowledgements

This project was inspired by roadmap.sh.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Packages

 
 
 

Contributors

Languages