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]`).

Related:

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

Co-authored-by: Victor Soto <[email protected]>
  • Loading branch information
2 people authored and darrachequesne committed Dec 29, 2020
1 parent 4ad26ee commit 52483f9
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 179 deletions.
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
Loading

0 comments on commit 52483f9

Please sign in to comment.