mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
[feat] Move binary detection to the parser (#1103)
This commit is contained in:
committed by
GitHub
parent
b4c7e49607
commit
ff4cb3eed0
@@ -9,7 +9,6 @@ var toArray = require('to-array');
|
||||
var on = require('./on');
|
||||
var bind = require('component-bind');
|
||||
var debug = require('debug')('socket.io-client:socket');
|
||||
var hasBin = require('has-binary');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
@@ -138,9 +137,7 @@ Socket.prototype.emit = function (ev) {
|
||||
}
|
||||
|
||||
var args = toArray(arguments);
|
||||
var parserType = parser.EVENT; // default
|
||||
if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary
|
||||
var packet = { type: parserType, data: args };
|
||||
var packet = { type: parser.EVENT, data: args };
|
||||
|
||||
packet.options = {};
|
||||
packet.options.compress = !this.flags || false !== this.flags.compress;
|
||||
@@ -289,9 +286,8 @@ Socket.prototype.ack = function (id) {
|
||||
var args = toArray(arguments);
|
||||
debug('sending ack %j', args);
|
||||
|
||||
var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK;
|
||||
self.packet({
|
||||
type: type,
|
||||
type: parser.ACK,
|
||||
id: id,
|
||||
data: args
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user