Adding error handler case in chat.js

We're going to do is add a few cases right here, in chat.js:

socket.on('connect', function () {
  var params = jQuery.deparam(window.location.search);

  socket.emit('join', params, function (err) {
    if(err) {

    } else {

    } 
  });
});

If it is an error that's a pretty big problem, and we're going to want to send the user back to the root of the application by changing one of the properties under location, window.location.href. Here we can manipulate which page the user's on, essentially we're going to be redirecting them back to that root page by having the forward slash (/) value set to the href property:

socket.on('connect', function () { var params = jQuery.deparam(window.location.search); socket.emit('join', params, ...

Get Advanced Node.js 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.