add task solution#124
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| JSON.stringify({ | ||
| type: 'message', | ||
| text: text.trim(), | ||
| }) |
There was a problem hiding this comment.
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.
| 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, | ||
| }); | ||
| } |
There was a problem hiding this comment.
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.
No description provided.