in this project i created two sides of the project(backend and frontend) to have a better and deeper understanding in web-sockets woth socket.io. also i need to mention that i used other tools which hepls me to develop this project better ,such as webpack and my beloved typescript .
- able to send messages in a public chat
- able to send messages to private chats or private users
- able to join a room or create a room for private conversation
- able to reply others while chating inside a room
Getting Started
for starting both client and server you need to go to each file and install all required dependencies :
for client:
cd client
npm install -y
npm run devfor server:
cd server
npm install -y
tsc // compile all typescript files to a javascript file to
// run it in server
npm run devand at the end you can open the index.html file and run a live server . and yes ,you did it .
Client: React, Redux, TailwindCSS
Server: Node, Express
some of the important files are elaborated down below:
A real-time chat application built using Socket.IO, allowing users to send messages to each other in public or private rooms.
- Real-time messaging using Socket.IO
- Public and private messaging
- Room support for private conversations
- Error handling for connection errors and disconnections
- Automatic scrolling to the bottom of the chat container
- ChatInputComponent: Handles user input and sends messages to the server
- MessageComponent: Displays individual messages in the chat container
- Header: Displays the chat header with the user's ID and connection status
connect: Establishes a connection to the serverrecieve-message: Receives messages from the server and displays them in the chat containerchat-header: Updates the chat header with the current room and connection statuserror: Handles error messages from the serverdisconnect: Handles disconnections from the serveroffline: Handles offline events from the serverconnect_error: Handles connection errors from the server
displayMessage: Displays a message in the chat container and sends it to the server if necessarydisplayChatHeader: Displays the chat header with the user's ID and connection status
A real-time chat server built using Socket.IO, allowing users to send messages to each other in public or private rooms.
- Real-time messaging using Socket.IO
- Public and private messaging
- Room support for private conversations
- Error handling for connection errors and disconnections
public-message: Sends a message to all connected clientsjoin-room: Joins a client to a specific roomleave-room: Leaves a client from a specific roomroom-message: Sends a message to all clients in a specific roomprivate-message: Sends a private message to a specific client FunctionsdisplayMessage: Displays a message in the chat container and sends it to the server if necessarydisplayChatHeader: Displays the chat header with the user's ID and connection status
Contributions are welcome! Please open a pull request to contribute to the project.
If you encounter any issues, please open an issue on GitHub.