Fixes event type when emitting binary_ack

When submitting binary data in an Ack to the server the packet's type
was not the expected (should be 6 - binary_ack - and not 3 - ack).

This commit introduces tests as well a fix for the given problem.
This commit is contained in:
Ciro S. Costa
2016-01-27 12:11:22 -03:00
parent 9ed41954ae
commit f0832ffc61
3 changed files with 76 additions and 1 deletions

View File

@@ -346,7 +346,13 @@ public class Socket extends Emitter {
sent[0] = true;
logger.fine(String.format("sending ack %s", args.length != 0 ? args : null));
int type = HasBinary.hasBinary(args) ? Parser.BINARY_ACK : Parser.ACK;
JSONArray jsonArgs = new JSONArray();
for (Object arg : args) {
jsonArgs.put(arg);
}
int type = HasBinary.hasBinary(jsonArgs)
? Parser.BINARY_ACK : Parser.ACK;
Packet<JSONArray> packet = new Packet<JSONArray>(type, new JSONArray(Arrays.asList(args)));
packet.id = id;
self.packet(packet);