'use strict';

/**
 * @ngdoc service
 * @name meanDemoApp.questionService
 * @description
 * # questionService
 * Factory in the meanDemoApp.
 */
angular.module('meanDemoApp')
  .factory('Question', function ($resource, $rootScope) {

    var rootUrl = 'http://192.168.1.113:4567';
    var apiRootUrl = rootUrl + '/api';

    broadcastEvents();

    return $resource(
      apiRootUrl + '/questions/:id',
      { id: '@id' },
      { vote: {
        method: 'POST',
        url: apiRootUrl + '/questions/:id/vote' }
      }
    );

    //////////////
    function broadcastEvents(){
        var socket = window.io.connect(rootUrl);

        socket.on('questionAdded', function (question) {
          $rootScope.$broadcast('questionAdded', question);
        });

        socket.on('questionDeleted', function (questionId) {
          $rootScope.$broadcast('questionDeleted', questionId);
        });

        socket.on('voteAdded', function (voteMsg) {
          $rootScope.$broadcast('voteAdded', voteMsg);
        });

    }
  });

@@ -258,21 +258,17 @@
 p://
-192.168.1.113
+localhost
 :456
@@ -525,27 +525,8 @@
 );%0A%0A
-    //////////////%0A
     
@@ -986,25 +986,24 @@
         %7D);%0A
-%0A
     %7D%0A  %7D);%0A

Revert accidentally hardcoding IP