diff --git a/curriculum/challenges/english/06-information-security-and-quality-assurance/advanced-node-and-express/announce-new-users.english.md b/curriculum/challenges/english/06-information-security-and-quality-assurance/advanced-node-and-express/announce-new-users.english.md index 30491df9ab..f4e59418f9 100644 --- a/curriculum/challenges/english/06-information-security-and-quality-assurance/advanced-node-and-express/announce-new-users.english.md +++ b/curriculum/challenges/english/06-information-security-and-quality-assurance/advanced-node-and-express/announce-new-users.english.md @@ -9,7 +9,7 @@ challengeType: 2 As a reminder, this project is being built upon the following starter project on Glitch, or cloned from GitHub. Many chat rooms are able to annouce when a user connects or disconnects and then display that to all of the connected users in the chat. Seeing as though you already are emitting an event on connect and disconnect, you will just have to modify this event to support such feature. The most logical way of doing so is sending 3 pieces of data with the event: name of the user connected/disconnected, the current user count, and if that name connected or disconnected.
io.emit('user', {name: socket.request.user.name, currentUsers, connected: true});
-Now your client will have all the nesesary information to correctly display the current user count and annouce when a user connects or disconnects! To handle this event on the client side we should listen for 'user' and then update the current user count by using jQuery to change the text of #num-users
to '{NUMBER} users online', as well as append a <li>
to the unordered list with id 'messages' with '{NAME} has {joined/left} the chat.'.
+Now your client will have all the necessary information to correctly display the current user count and annouce when a user connects or disconnects! To handle this event on the client side we should listen for 'user' and then update the current user count by using jQuery to change the text of #num-users
to '{NUMBER} users online', as well as append a <li>
to the unordered list with id 'messages' with '{NAME} has {joined/left} the chat.'.
An implementation of this could look like the following:socket.on('user', function(data){ $('#num-users').text(data.currentUsers+' users online'); var message = data.name;