Commit c46d448 1 parent d821900 commit c46d448 Copy full SHA for c46d448
File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -141,13 +141,14 @@ Socket.prototype.emit = function(ev){
141
141
emit . apply ( this , arguments ) ;
142
142
} else {
143
143
var args = Array . prototype . slice . call ( arguments ) ;
144
- var packet = { } ;
145
- packet . type = hasBin ( args ) ? parser . BINARY_EVENT : parser . EVENT ;
146
- packet . data = args ;
144
+ var packet = {
145
+ type : hasBin ( args ) ? parser . BINARY_EVENT : parser . EVENT ,
146
+ data : args
147
+ } ;
147
148
var flags = this . flags || { } ;
148
149
149
150
// access last argument to see if it's an ACK callback
150
- if ( 'function' == typeof args [ args . length - 1 ] ) {
151
+ if ( typeof args [ args . length - 1 ] === 'function' ) {
151
152
if ( this . _rooms || flags . broadcast ) {
152
153
throw new Error ( 'Callbacks are not supported when broadcasting' ) ;
153
154
}
@@ -495,15 +496,16 @@ Socket.prototype.compress = function(compress){
495
496
Socket . prototype . dispatch = function ( event ) {
496
497
debug ( 'dispatching an event %j' , event ) ;
497
498
var self = this ;
498
- this . run ( event , function ( err ) {
499
+ function dispatchSocket ( err ) {
499
500
process . nextTick ( function ( ) {
500
501
if ( err ) {
501
502
return self . error ( err . data || err . message ) ;
502
503
}
503
504
emit . apply ( self , event ) ;
504
505
} ) ;
505
- } ) ;
506
- }
506
+ }
507
+ this . run ( event , dispatchSocket ) ;
508
+ } ;
507
509
508
510
/**
509
511
* Sets up socket middleware.
You can’t perform that action at this time.
0 commit comments