Skip to content

Proposal socket chat project#177

Open
ht1204 wants to merge 2 commits intomate-academy:masterfrom
ht1204:develop
Open

Proposal socket chat project#177
ht1204 wants to merge 2 commits intomate-academy:masterfrom
ht1204:develop

Conversation

@ht1204
Copy link
Copy Markdown

@ht1204 ht1204 commented Feb 26, 2026

Description

  • Proposal socket chat

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This is a strong submission with a well-structured server. However, changes are needed for the room deletion feature, as it contains a critical bug that breaks functionality for users.

In src/controllers/socketController.js, when a room is deleted, users are moved to the 'General' room, but their currentRoom state on the server is not updated. This inconsistency prevents those users from sending any further messages. The issue is that io.in(roomId).socketsJoin(...) only changes the socket's subscription but doesn't update the currentRoom variable held in the socket's closure.

To fix this, consider emitting a dedicated event to the clients in the deleted room. The clients can then handle this event by emitting a room:join event for the 'General' room, which will correctly update their state on both the client and server. Once you resolve this state management issue, the application should be fully functional.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +127 to +128
io.in(roomId).socketsJoin(store.DEFAULT_ROOM_ID);
io.in(roomId).socketsLeave(roomId);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach to moving users from a deleted room is problematic. While socketsJoin and socketsLeave correctly change the socket's room subscription at the socket.io level, they don't update the currentRoom variable (defined on line 8) for each affected socket connection. This leads to a state inconsistency where the server thinks the user is still in the old room, causing subsequent actions like sending a message to fail.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Excellent work on this submission! I am approving your solution as you've successfully addressed the critical bug with room deletion. The application is now fully functional, correctly synchronizing state between the client and server. Your code is well-structured, clean, and meets all the specified requirements. Great job!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants