Author: Martynas Prascevicius University: University of Greenwich Course: COMP1549 - Network and Operating System Principles Year: 2024-25
MPchat is a multi-client chat application built with JavaFX, demonstrating concurrent networking, server-client architecture, and GUI development in Java. The application supports multiple simultaneous client connections with a custom-styled graphical interface.
- Multi-threaded Server - Handles multiple concurrent client connections
- JavaFX GUI - Modern graphical interface with custom styling
- Real-time Messaging - Instant message broadcasting to all connected clients
- Unit Testing - JUnit test suite for server functionality
- Custom Styling - CSS-based theming with background images
- Language: Java (OpenJDK 23.0.2)
- GUI Framework: JavaFX 23.0.2
- Testing: JUnit 4.13.2
- Build Tool: Manual compilation (shell scripts)
- Architecture: Server-client model with multi-threading
MPchat/
├── src/
│ ├── Server.java # Multi-threaded server implementation
│ ├── ClientHandler.java # Handles individual client connections
│ ├── ChatClient.java # JavaFX client GUI
│ ├── MyMessageBox.java # Custom message box component
│ ├── ServerTest.java # JUnit test suite
│ ├── styles.css # Custom CSS styling
│ └── bg.png # Background image asset
├── lib/ # JUnit and Hamcrest libraries
└── javafx-sdk-23.0.2/ # JavaFX SDK (not included in repo)
- Java Development Kit (JDK) 21+
- JavaFX SDK 23.0.2 - Download here
- macOS/Linux environment (scripts are bash-based)
-
Clone the repository:
git clone https://github.com/mp-c0de/MPchat-JavaFX.git cd MPchat-JavaFX -
Download and extract JavaFX SDK 23.0.2 into the
MPchat/directory:MPchat/javafx-sdk-23.0.2/
java MPchat/src/Server.java 2000The server will start listening on port 2000.
Use the provided script to start multiple client windows:
bash sclients.sh 3This will open 3 JavaFX client windows that can communicate with each other.
bash runtests.shThis executes the JUnit test suite for the server functionality.
The server uses a multi-threaded architecture:
- Main server thread accepts incoming connections on a specified port
- Each client connection is handled by a separate
ClientHandlerthread - Messages are broadcast to all connected clients in real-time
- Thread-safe message distribution using concurrent collections
The JavaFX client provides:
- Text input field for composing messages
- Message display area showing chat history
- Send button for submitting messages
- Custom CSS styling with background image
- Automatic reconnection handling
The project includes a comprehensive JUnit test suite (ServerTest.java) that verifies:
- Server initialisation and port binding
- Multiple concurrent client connections
- Message broadcasting functionality
- Graceful shutdown and resource cleanup
Run tests:
bash runtests.sh- Multiple clients can connect simultaneously
- Each client operates independently in its own thread
- No blocking between client operations
- Messages are instantly broadcast to all connected clients
- Server maintains a list of active connections
- Clients can join or leave at any time
- Custom JavaFX interface with CSS styling
- Responsive layout design
- Visual feedback for user actions
This project demonstrates proficiency in:
- Networking: Socket programming, server-client architecture
- Concurrency: Multi-threading, thread synchronisation, concurrent collections
- GUI Development: JavaFX, event handling, CSS styling
- Testing: JUnit unit testing, test-driven development
- Software Engineering: Clean code structure, separation of concerns
- OS: macOS Sequoia 15.3.2
- Java: OpenJDK 23.0.2
- Shell: zsh
- No authentication or user management
- No message persistence (chat history is lost on disconnect)
- Fixed port configuration (hardcoded to 2000)
- No encryption (plain text communication)
- Add user authentication
- Implement message history storage
- Add private messaging between specific clients
- Integrate TLS/SSL for secure communication
- Create configuration file for server settings
This project was created for academic purposes as part of university coursework.
Martynas Prascevicius 📧 Email: mpcode@icloud.com 💼 LinkedIn: linkedin.com/in/mpc0de 🐙 GitHub: github.com/mp-c0de
Built with ❤️ for COMP1549 coursework at University of Greenwich