File tree 2 files changed +6
-0
lines changed
2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
var debug = require ( 'debug' ) ( 'socket.io-parser' ) ;
7
7
var Emitter = require ( 'component-emitter' ) ;
8
+ var hasBin = require ( 'has-binary2' ) ;
8
9
var binary = require ( './binary' ) ;
9
10
var isBuf = require ( './is-buffer' ) ;
10
11
@@ -123,6 +124,10 @@ function Encoder() {}
123
124
*/
124
125
125
126
Encoder . prototype . encode = function ( obj , callback ) {
127
+ if ( ( obj . type === exports . EVENT || obj . type === exports . ACK ) && hasBin ( obj . data ) ) {
128
+ obj . type = obj . type === exports . EVENT ? exports . BINARY_EVENT : exports . BINARY_ACK ;
129
+ }
130
+
126
131
debug ( 'encoding packet %j' , obj ) ;
127
132
128
133
if ( exports . BINARY_EVENT === obj . type || exports . BINARY_ACK === obj . type ) {
Original file line number Diff line number Diff line change 14
14
"dependencies" : {
15
15
"debug" : " 2.3.3" ,
16
16
"component-emitter" : " 1.2.1" ,
17
+ "has-binary2" : " 1.0.1" ,
17
18
"isarray" : " 2.0.1"
18
19
},
19
20
"devDependencies" : {
You can’t perform that action at this time.
0 commit comments