Skip to content

Commit 52483f9

Browse files
jvictorsotoVictor Soto
authored andcommitted
fix(binary): fix binary events being marked as regular events (#76)
So that the emitter can send binary payloads to a Socket.IO server (only applies to `socket.io@2.1.0...2.x`). Related: - socketio/socket.io-parser@dc4f475 - socketio/socket.io@f48a06c Co-authored-by: Victor Soto <jesus_victor.soto_munoz@nokia.com>
1 parent 4ad26ee commit 52483f9

File tree

3 files changed

+228
-179
lines changed

3 files changed

+228
-179
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
var client = require('redis').createClient;
77
var parser = require('socket.io-parser');
88
var msgpack = require('notepack.io');
9+
var hasBin = require('has-binary2');
910
var debug = require('debug')('socket.io-emitter');
1011

1112
/**
@@ -123,7 +124,7 @@ Emitter.prototype.of = function(nsp){
123124
Emitter.prototype.emit = function(){
124125
// packet
125126
var args = Array.prototype.slice.call(arguments);
126-
var packet = { type: parser.EVENT, data: args, nsp: this.nsp };
127+
var packet = { type: hasBin(args) ? parser.BINARY_EVENT : parser.EVENT, data: args, nsp: this.nsp };
127128

128129
var opts = {
129130
rooms: this._rooms,

0 commit comments

Comments
 (0)