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 which calls the issues method and one for commits which calls the commits method. The join method will now emit an Socket.IO unsubscribe
event unsubscribing the user from any currently subscribed projects. It will then emit a Socket.IO subscribe...