dist/ember-sockets.js
/**
         * Responsible for listening to events from Socket.io, and updating controller properties that
         * subscribe to those events.
         *
         * @method _listen
         * @return {void}
         * @private
         */
Responsible for listening to events from Socket.io, and updating controller properties that
subscribe to those events.

@method _listen
@return {void}
@private
Responsible for listening to events from Socket . io and updating controller properties that subscribe to those events . @method _listen @return { void } @private
function _listen() {
            var controllers     = $ember.get(this, 'controllers'),
                getController   = Ember.run.bind(this, this._getController),
                events          = [],
                forEach         = Array.prototype.forEach,
                module          = this,
                respond         = function respond() {
                    var eventData = Array.prototype.slice.call(arguments);
                    module._update.call(module, this, eventData);
                };
            forEach.call(controllers, function controllerIteration(controllerName) {
                var controller  = getController(controllerName),
                    eventNames  = controller[this.NAMESPACE];
                if (controller) {
                    if (typeof controller[this.NAMESPACE] === 'object' && typeof controller[this.NAMESPACE].connect === 'function') {
                        controller[this.NAMESPACE].connect.apply(controller);
                    }
                    for (var eventName in eventNames) {
                        if (eventNames.hasOwnProperty(eventName)) {
                            if (events.indexOf(eventName) !== -1) {
                                continue;
                            }
                            events.push(eventName);
                            $ember.get(module, 'socket').removeAllListeners(eventName)
                            $ember.get(module, 'socket').on(eventName, respond.bind(eventName));
                        }
                    }
                }
            }, this);
        }
function _listen ( ) { var controllers = $ember . get ( this , 'controllers' ) , getController = Ember . run . bind ( this , this . _getController ) , events = [ ] , forEach = Array . prototype . forEach , module = this , respond = function respond ( ) { var eventData = Array . prototype . slice . call ( arguments ) ; module . _update . call ( module , this , eventData ) ; } ; forEach . call ( controllers , function controllerIteration ( controllerName ) { var controller = getController ( controllerName ) , eventNames = controller [ this . NAMESPACE ] ; if ( controller ) { if ( typeof controller [ this . NAMESPACE ] === 'object' && typeof controller [ this . NAMESPACE ] . connect === 'function' ) { controller [ this . NAMESPACE ] . connect . apply ( controller ) ; } for ( var eventName in eventNames ) { if ( eventNames . hasOwnProperty ( eventName ) ) { if ( events . indexOf ( eventName ) !== - 1 ) { continue ; } events . push ( eventName ) ; $ember . get ( module , 'socket' ) . removeAllListeners ( eventName ) $ember . get ( module , 'socket' ) . on ( eventName , respond . bind ( eventName ) ) ; } } } } , this ) ; }
Responsible for listening to events from Socket.io, and updating controller properties that
 subscribe to those events.
Responsible for listening to events from Socket . io and updating controller properties that subscribe to those events .
// Fetch the controller if it's valid. // Invoke the `connect` method if it has been defined on this controller. // Iterate over each event defined in the controller's `sockets` hash, so that we can // keep an eye open for them. // Don't observe this event if we're already observing it. // Push the event so we don't listen for it twice. // Remove all previous registrations (possible in the case of reconnects) // ...And finally we can register the event to listen for it.