Skip to content

add task solution#124

Open
anastasia-maidanyuk wants to merge 1 commit into
mate-academy:masterfrom
anastasia-maidanyuk:develop
Open

add task solution#124
anastasia-maidanyuk wants to merge 1 commit into
mate-academy:masterfrom
anastasia-maidanyuk:develop

Conversation

@anastasia-maidanyuk
Copy link
Copy Markdown

No description provided.

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

Great job! 🎉 Your implementation meets all the core requirements and constraints of the task. The only minor point is to ensure the client always sends a 'join' message before sending chat messages, as the server relies on this for correct message routing. Otherwise, everything looks solid—keep up the good work!


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

Footnotes

  1. Rate AI review example

Comment on lines +64 to +67
JSON.stringify({
type: 'message',
text: text.trim(),
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Potential issue: The message payload sent on submit does not include the roomId. If your backend expects the roomId to be present in each message (not just on join), you should add roomId to this payload. Please verify the backend requirements.

Comment thread src/index.js
Comment on lines +80 to +93
if (type === 'message') {
const msg = {
author: ws.username,
time: new Date().toISOString(),
text: message.text,
};

roomManager.addMessage(ws.roomId, msg);

roomManager.broadcast(ws.roomId, {
type: 'message',
message: msg,
});
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Potential issue: The server expects ws.roomId to be set from a previous 'join' message before processing 'message' events. If a client sends a 'message' before joining a room, ws.roomId will be undefined, and the message may not be routed correctly. Consider validating ws.roomId before processing, or ensure the client always sends a 'join' message first.

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