Repository navigation
London | 26-SDC-July | Raihan Sharif | Sprint 2 | Chat-app - #124
RaihanSharif wants to merge 53 commits into
Conversation
Can post message, with validation. Can get all messages.
Only return list of messages, or a single message. Clean up js doc
Messages can now be fetched or created using REST API. Client can then fetch subsequent messages using event streaming.
create new message handling function.
Extract common code for the web socket and polling versions.
|
Update: I have now created the two separate apps, one polling and one Websocket. Both try to reuse as much code as possible, both in the frontend and backend. Backend:
Frontend:
Application uses HTTP post to create new messages and reactions and event streaming through either long polling or websocket to read new events. Has some functionality to avoid race conditions by using even cursor per client. |
This comment has been minimized.
This comment has been minimized.
LonMcGregor
left a comment
There was a problem hiding this comment.
Good work building this app, you've organised the files neatly and used classes where appropriate. I can also see places where you've given consideration to how you could extend with new functionality later.
I have spotted a few areas where you could improve, or where you could answer my questions to check your understanding of the code.
| /** | ||
| * Sends new events for each waiting request, if there are any events to send. | ||
| */ | ||
| notifyWaiters() { |
There was a problem hiding this comment.
What is the difference between a "waiter" and a "subscriber"?
There was a problem hiding this comment.
In this code waiters are the polling requests, and subscribers are WebSocket connections.
I was going to create a more general "subscriber" interface so that both WebSocket and HTTP, but I didn't have the time to get it done.
I've added some comments to make this clearer.
There was a problem hiding this comment.
That makes sense. Adding comments is a good way to reduce ambiguity, thanks for adding them. If you encounter this again, another approach could be to change the variable names themselves to make the distinction more clear
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for answering my questions, this is complete now |
Learners, PR Template
Self checklist
Task code
CYF-1162
Changelist
Created a live updating chat app that allows client to use either long polling or short polling.
Users can add new message
User is notified whenever a new message is created by another user
User can like or dislike a message
User is notified when a message is liked/disliked
backend: https://z4k2yzxetkpevkwf6zy9ea37.trainees.hosting.cyf.academy/messages
frontend: https://qhdyqohwxffxraktvwh1e0ys.trainees.hosting.cyf.academy/