Let's try something a little more complex, and closer to the intended purpose of Socket.IO. Let's implement a way for Notes' users to send each other messages within Notes.
When a user logs in, and they have messages, we'll show those messages in a box at the top of the screen. We'll also allow the user to delete those messages, and of course to send messages to themselves or other users.
Let's get started.
The events we'll be sending and receiving are:
newmessage: This event indicates that a message has been created. It includes the user ID of the recipient of the message. It's sent from the server, and the code in the browser is to retrieve the current list of messages. ...