Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Conversation

bipoool
Copy link
Contributor

@bipoool bipoool commented May 11, 2025

DiceDB Java Chatroom

A terminal-based chatroom application built in Java using DiceDB and the DiceDB-Java SDK. Each instance of the application connects to a shared DiceDB backend and communicates in real-time through a simple terminal interface.


⚙️ Requirements

  • Java 21
  • Maven (use included mvnw wrapper)
  • DiceDB running locally on port 7379

Make sure DiceDB is up and running before you start the application.
Refer to DiceDB README for setup instructions.


🚀 Running the Application

Using JAR

To build and run the JAR:

# Step 1: Build the jar
./mvnw clean install

# Step 2: Run the jar with a username
java -jar target/chatroom.jar <username1>
java -jar target/chatroom.jar <username2>

Using Docker

To build and run the Container:

# Step 1: Build the jar
./mvnw clean install

# Step 2: Run DiceDB docker container first
docker-compose up -d dicedb

# Step 3: Run Container for each chatroom session
docker-compose run chatroom username1
docker-compose run chatroom username2

💬 Interface Instructions

1. A popup terminal window will appear.

2. Type your message in the input box.

3. Use the Left Arrow Key to shift focus to the Send button.

4. Press Enter to send the message.

5. Write 'exit' to leave the chatroom.

📸 Screenshots

image

@bipoool bipoool force-pushed the feature/chatroom-java branch from b0215ca to 1ca5ea3 Compare May 13, 2025 15:44

public void receiveMessage() {
this.executorService.submit(() -> {
while (true) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will keep looping even if the thread gets interrupted. That's not expected, right?

You can put the try-catch outside the while loop, and update the while condition as

while (!Thread.currentThread().isInterrupted()

Copy link
Contributor Author

@bipoool bipoool May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm stopping this thread via the close function. The print statement is misleading. Will fix it and add a break after that as well.

Thanks for your suggestion, I'll make some changes around it for better readability.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants