Skip to content

Commit

Permalink
fix(binary): fix binary events being marked as regular events (#76)
Browse files Browse the repository at this point in the history
So that the emitter can send binary payloads to a Socket.IO server
(only applies to `[email protected]`).

Note: we should remove this in the future, as it is not needed for a
Socket.IO v3 server.

Related:

- socketio/socket.io-parser@dc4f475
- socketio/socket.io@f48a06c

Co-authored-by: Victor Soto <[email protected]>
  • Loading branch information
jvictorsoto and Victor Soto authored Dec 29, 2020
1 parent 009b5b8 commit 4052747
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var client = require('redis').createClient;
var parser = require('socket.io-parser');
var msgpack = require('notepack.io');
var hasBin = require('has-binary2');
var debug = require('debug')('socket.io-emitter');

/**
Expand Down Expand Up @@ -123,7 +124,7 @@ Emitter.prototype.of = function(nsp){
Emitter.prototype.emit = function(){
// packet
var args = Array.prototype.slice.call(arguments);
var packet = { type: parser.EVENT, data: args, nsp: this.nsp };
var packet = { type: hasBin(args) ? parser.BINARY_EVENT : parser.EVENT, data: args, nsp: this.nsp };

var opts = {
rooms: this._rooms,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"dependencies": {
"debug": "~3.1.0",
"has-binary2": "~1.0.2",
"notepack.io": "~2.1.0",
"redis": "2.6.3",
"socket.io-parser": "3.1.2"
Expand Down

0 comments on commit 4052747

Please sign in to comment.