text: 'use strict';
  
  /**
   * @ngdoc service
   * @name TodoList.Socket
   * @description
   * # Socket
   * Service in the TodoList.
   */
  angular.module('TodoList')
    .service('Socket', ['$rootScope',function ($rootScope) {
      var socket = io.connect(socketPath);
      return {
        on: function (eventName, callback) {
          socket.on(eventName, function () {
            var args = arguments;
            $rootScope.$apply(function () {
              callback.apply(socket, args);
            });
          });
        },
        emit: function (eventName, data, callback) {
          socket.emit(eventName, data, function () {
            var args = arguments;
            $rootScope.$apply(function () {
              if (callback) {
                callback.apply(socket, args);
              }
            });
          })
        }
      };
  
    }]);
  