Running the Notes application with Socket.IO
Now we're ready to run the application. First do this to ensure that the socket.IO library is installed, because of the dependency added in package.json
earlier.
$ npm install
Then run the application as before:
$ node app.js
Then you will be greeted with the familiar home page:
You will be able to log in as normal:
And you can take the application through its normal paces. The new behavior shows itself when you have multiple browsers connected to the application.
When viewing the home page in one browser, watch what happens as you create, update, or delete notes in another browser. Likewise, if viewing a note in a browser, watch what happens as you edit or delete that note in another browser.
As you run the server, it will print a running log of the Socket.IO activity, letting you see what it's doing:
debug - client authorized info - handshake authorized m4MA-s-U5PflPo08kMJL debug - setting request GET /socket.io/1/websocket/m4MA-s-U5PflPo08kMJL...