Implement one-to-one real-time chat using Socket.IO#1382
Implement one-to-one real-time chat using Socket.IO#1382gaurav123-4 wants to merge 3 commits intoCode-A2Z:mainfrom
Conversation
|
@gaurav123-4 is attempting to deploy a commit to the avdheshvarshney's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for submitting your pull request! We'll review it as soon as possible. For further communication, join our discord server https://discord.gg/tSqtvHUJzE. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@gaurav123-4 Please check your FE deployment has failed. |
Avdhesh-Varshney
left a comment
There was a problem hiding this comment.
@gaurav123-4 Great Work.
Display all the registered users but on later will display the status on user on avatar like a green dot (for online users) otherwise empty dot (for offline users).
Please share me a working demo video of this whole current state of the feature.
| @@ -0,0 +1,4 @@ | |||
| export const CHATS_SIDEBAR_WIDTH = 280; | |||
There was a problem hiding this comment.
Increase width to 300px
There was a problem hiding this comment.
Remove changes from this file
|
@gaurav123-4 You have forget to remove the lock from this icon. |


Pull Requests Review Criteria
Caution
PRs that fail to meet these review standards will be automatically flagged and may be rejected by maintainers.
mainCloses: #1380
Describe the add-ons or changes you've made 📃
Implementation Summary
Files Created/Updated:
Database Schema & Model:
src/schemas/message.schema.js - Message schema with sender/receiver, read status, and indexes
src/models/message.model.js - Message model
Updated src/constants/db.js - Added MESSAGES collection
Socket.IO Server:
src/config/socket.io.js - Socket.IO server with:
JWT authentication middleware
Connection management
Real-time event handlers
REST API Controllers:
src/controllers/chat/get-messages.js - Get conversation messages
src/controllers/chat/get-conversations.js - Get list of conversations
Routes:
Updated src/routes/api/chat.routes.js - Added endpoints for messages and conversations
Server Integration:
Updated index.js - Initialize Socket.IO with HTTP server
Updated src/stores/online-users.js - Added removePresence function
Updated package.json - Added socket.io dependency
Socket.IO Events:
Client → Server:
message:send - Send a message to another user
typing:start - Indicate user is typing
typing:stop - Stop typing indicator
message:read - Mark messages as read
Server → Client:
message:sent - Confirmation message was sent
message:receive - Receive a new message
message:read - Notification that messages were read
typing:start - User started typing
typing:stop - User stopped typing
user:online - User came online
user:offline - User went offline
message:error - Error occurred
REST API Endpoints:
GET /api/chat/conversations - Get all conversations for current user
GET /api/chat/messages/:userId - Get messages with a specific user (supports pagination)
Screenshots 📷
Note to reviewers (Optional) 📄