Socket.IO on the client
In order to display these Socket.IO published messages, we need to make some client changes. Let's install the Socket.IO client piece using bower:
bower install socketio-client
Let's make a single change to our ./lib/express/index.js
Express server and simplify the location of our socket.io-client
using the static
middleware:
app.use('/sockets', express.static('public/components/socket.io-client/dist/'));
We will now add the Socket.IO client scripts to ./views/index.html
:
<script src="/sockets/socket.io.js"></script>
Now we integrate Socket.IO into our backbone piece. Let's update our Backbone.js Router
. The router initialise
method now accepts socket
as an argument and contains two Socket.IO event handlers: one for issues ...
Get Advanced Express Web Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.