ChatFlow is a chat application written in Java 23, using Swing for the graphical user interface (GUI). It allows multiple clients to connect to a central server using Java Sockets. The communication between the client and server is encrypted using RSA encryption, ensuring secure message transmission.
- Client-Server Model: Clients connect to the server using an IP address and port.
- Username System: Users must enter a username that is not being used to join the chat.
- RSA Encryption: Messages exchanged between client and server are encrypted for security.
- Message History: Upon connection, a client automatically receives all previous messages.
- Shared Models and Encryption: The models and encryption logic are shared between the client and server to maintain consistency.
- MVC Architecture: The client follows the Model-View-Controller (MVC) pattern for better organization and separation of concerns.
- Multi-Threading: Both the client and server handle sending and receiving messages in separate threads.
- Server-Side Logging: The server logs each operation and exception.
- Built-in Bot: A server bot provides predefined commands to interact with users.
Some classes, especially the models, are shared between client and server. That reduce the possibility of making mistakes, while actively apply the DRY principle (Don't Repeat Yourself!). Apart from the models, classes used for encryption, serialization and in general communication, are included there.
- ChatModel - Stores all messages sent in the chat.
- MessageModel - Defines a message with:
message: The message text.sender: A UserModel instance representing the sender.date: The timestamp of the message.
- UserModel - Represents a user with a username.
- ServerConnectionView - Allows users to enter the server IP and port.
- LoginView - Allows users to enter a unique username.
- ChatView - Displays all messages and provides an input field for sending new ones.
- ServerConnectionController - Manages the server connection process.
- LoginController - Handles user authentication (unique username requirement).
- ChatController - Manages chat interactions, message encryption, and UI updates.
- Sending and receiving messages are handled in separate threads.
- Messages are serialized and encrypted before transmission.
- Incoming messages are decrypted, deserialized, and displayed in the UI.
- Errors and exceptions are displayed via popup alerts.
- ServerMain - Controls the ServerSocket and listens for incoming client connections.
- ClientHandler - Manages communication with a single connected client. Each client has a dedicated
ClientHandlerinstance. - ServerBot - Provides automated responses to user commands.
- Each client has two separate threads on the server:
- One for receiving messages.
- One for sending messages.
- Messages are serialized, encrypted, and transmitted securely.
The ServerBot responds to the following commands:
/date - Get the current date and time
/random - Generate a random number (1-100)
/whoami - Find out your username
/users - Get a list of connected users
/coin - Flip a coin (heads or tails)
/size - Get the chat size
/help - Show the help message
Download ChatFlow_client.jar & ChatFlow_server.jar from the release section!
- Run
java -jar ChatFlow_server.jar. - The server will start listening for client connections.
- Logs will be generated for each operation.
- Run
java -jar ChatFlow_client.jar. - Enter the server IP address and port.
- Choose a unique username.
- Start chatting!
- RSA Encryption: All messages are encrypted before transmission.
- Serialized Object Encryption: Objects are serialized and encrypted before being sent.
- Unique Usernames: The same user can only be actively used by one client simultaneously.
ChatFlow is an open-source project, created as an educational project!