11/* global angular: false */
2- var ng = angular . module ( " btford.socket-io" , [ ] )
3- ng . provider ( " socketFactory" , function ( ) {
2+ var ng = angular . module ( ' btford.socket-io' , [ ] )
3+ ng . provider ( ' socketFactory' , function ( ) {
44 this . $get = function ( $rootScope ) {
55
6- return function ( ) {
7- var obj = { }
8- obj . events = { }
9- obj . emits = { }
6+ var obj = { }
7+ obj . events = { }
8+ obj . emits = { }
109
11- // intercept 'on' calls and capture the callbacks
12- obj . on = function ( eventName , callback ) {
13- if ( ! this . events [ eventName ] ) this . events [ eventName ] = [ ]
14- this . events [ eventName ] . push ( callback )
15- }
10+ // intercept 'on' calls and capture the callbacks
11+ obj . on = function ( eventName , callback ) {
12+ if ( ! this . events [ eventName ] ) this . events [ eventName ] = [ ]
13+ this . events [ eventName ] . push ( callback )
14+ }
1615
17- // intercept 'emit' calls from the client and record them to assert against in the test
18- obj . emit = function ( eventName ) {
19- var args = Array . prototype . slice . call ( arguments , 1 )
16+ // intercept 'emit' calls from the client and record them to assert against in the test
17+ obj . emit = function ( eventName ) {
18+ var args = Array . prototype . slice . call ( arguments , 1 )
2019
21- if ( ! this . emits [ eventName ] )
22- this . emits [ eventName ] = [ ]
23- this . emits [ eventName ] . push ( args )
24- }
20+ if ( ! this . emits [ eventName ] )
21+ this . emits [ eventName ] = [ ]
22+ this . emits [ eventName ] . push ( args )
23+ }
2524
26- //simulate an inbound message to the socket from the server (only called from the test)
27- obj . receive = function ( eventName ) {
28- var args = Array . prototype . slice . call ( arguments , 1 )
25+ //simulate an inbound message to the socket from the server (only called from the test)
26+ obj . receive = function ( eventName ) {
27+ var args = Array . prototype . slice . call ( arguments , 1 )
2928
30- if ( this . events [ eventName ] ) {
29+ if ( this . events [ eventName ] ) {
3130
32- angular . forEach ( this . events [ eventName ] , function ( callback ) {
33- $rootScope . $apply ( function ( ) {
31+ angular . forEach ( this . events [ eventName ] , function ( callback ) {
32+ $rootScope . $apply ( function ( ) {
3433
35- callback . apply ( this , args )
36- } )
34+ callback . apply ( this , args )
3735 } )
38- }
36+ } )
3937 }
38+ }
4039
41- return obj
42- } ;
40+ return obj
4341 }
4442} )
0 commit comments