This chat application allows clients to connect to a server and participate in chat rooms.
- View a list of existing chat rooms
- View the number and list of connected users for each room
- Join existing chat rooms if there is capacity
- Create chat rooms
- Send messages to chat rooms
- Leave a chat room
From your terminal in the root directory of this project,
javac -d bin src\*.java
First, Start the server by running the Server class.
java -cp bin\ Server
Second, Start the client by running the Client class.
java -cp bin\ Client
Follow the prompts in the client interface to connect to the server and participate in chat rooms.
A dash -
is command mode.
-createRoom 'room_Name'
without the quotes.-rooms
to list all the rooms.-join 1
to join room number 1. It starts from 0.-rDetails
current room details.-leave
to leave to current room.
- How to use sockets and TCP connections to create a client-server application in Java.
- How to send and receive data over a network connection.
- How to design and implement a simple chat application with multiple chat rooms.
- The importance of thread safety when working with concurrent connections.
After entering the username, the client gets connected to the server via TCP:
First a room has to be created in order to see the room list. Via -createRoom room_Name
Now list rooms by -rooms
Write -join "room number"
without the quotes to join. Room number starts from 0, 1, ...
From any client, write -rDetails
Now initiating 6 clients in total, 5 will be joining in one room, the 6th client won’t be able to join on that room.
Write -createRoom room_name
to create a room.
Write -leave
to leave the room from any client. Other connected clients in the room will be informed.