Fix #62, binary arguments in emit with ack

This commit is contained in:
Alfio Emanuele Fresta
2014-11-25 00:04:47 +00:00
parent 6f56aa6d67
commit f06d9b1803

View File

@@ -173,8 +173,7 @@ public class Socket extends Emitter {
for (Object arg : _args) { for (Object arg : _args) {
jsonArgs.put(arg); jsonArgs.put(arg);
} }
int parserType = Parser.EVENT; int parserType = HasBinary.hasBinary(jsonArgs) ? Parser.BINARY_EVENT : Parser.EVENT;
if (HasBinary.hasBinary(jsonArgs)) { parserType = Parser.BINARY_EVENT; }
Packet<JSONArray> packet = new Packet<JSONArray>(parserType, jsonArgs); Packet<JSONArray> packet = new Packet<JSONArray>(parserType, jsonArgs);
if (_args.get(_args.size() - 1) instanceof Ack) { if (_args.get(_args.size() - 1) instanceof Ack) {
@@ -229,7 +228,13 @@ public class Socket extends Emitter {
addAll(Arrays.asList(args)); addAll(Arrays.asList(args));
} }
}}; }};
Packet<JSONArray> packet = new Packet<JSONArray>(Parser.EVENT, new JSONArray(_args));
JSONArray jsonArgs = new JSONArray();
for (Object _arg : _args) {
jsonArgs.put(_arg);
}
int parserType = HasBinary.hasBinary(jsonArgs) ? Parser.BINARY_EVENT : Parser.EVENT;
Packet<JSONArray> packet = new Packet<JSONArray>(parserType, jsonArgs);
logger.fine(String.format("emitting packet with ack id %d", ids)); logger.fine(String.format("emitting packet with ack id %d", ids));
Socket.this.acks.put(ids, ack); Socket.this.acks.put(ids, ack);