@Test public void testEncodePayloadAsBinary_empty() { ServerParser.encodePayloadAsBinary(new ArrayList<>(), data -> assertArrayEquals(data, new byte[0])); }
@SuppressWarnings("Duplicates") public static void encodePayloadAsBinary(List<Packet<?>> packets, Parser.EncodeCallback<byte[]> callback) { if (packets.size() == 0) { callback.call(new byte[0]); return; } final ArrayList<byte[]> results = new ArrayList<>(packets.size()); for (Packet packet : packets) { encodePacket(packet, true, packet1 -> { if (packet1 instanceof String) { String encodingLength = String.valueOf(((String) packet1).length()); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)0; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, ((String) packet1).getBytes(StandardCharsets.UTF_8) })); } else { String encodingLength = String.valueOf(((byte[]) packet1).length); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)1; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, (byte[]) packet1 })); } }); } callback.call(Buffer.concat(results.toArray(new byte[results.size()][]))); }
ServerParser { @SuppressWarnings("Duplicates") public static void encodePayloadAsBinary(List<Packet<?>> packets, Parser.EncodeCallback<byte[]> callback) { if (packets.size() == 0) { callback.call(new byte[0]); return; } final ArrayList<byte[]> results = new ArrayList<>(packets.size()); for (Packet packet : packets) { encodePacket(packet, true, packet1 -> { if (packet1 instanceof String) { String encodingLength = String.valueOf(((String) packet1).length()); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)0; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, ((String) packet1).getBytes(StandardCharsets.UTF_8) })); } else { String encodingLength = String.valueOf(((byte[]) packet1).length); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)1; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, (byte[]) packet1 })); } }); } callback.call(Buffer.concat(results.toArray(new byte[results.size()][]))); } }
ServerParser { @SuppressWarnings("Duplicates") public static void encodePayloadAsBinary(List<Packet<?>> packets, Parser.EncodeCallback<byte[]> callback) { if (packets.size() == 0) { callback.call(new byte[0]); return; } final ArrayList<byte[]> results = new ArrayList<>(packets.size()); for (Packet packet : packets) { encodePacket(packet, true, packet1 -> { if (packet1 instanceof String) { String encodingLength = String.valueOf(((String) packet1).length()); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)0; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, ((String) packet1).getBytes(StandardCharsets.UTF_8) })); } else { String encodingLength = String.valueOf(((byte[]) packet1).length); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)1; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, (byte[]) packet1 })); } }); } callback.call(Buffer.concat(results.toArray(new byte[results.size()][]))); } private  ServerParser(); }
ServerParser { @SuppressWarnings("Duplicates") public static void encodePayloadAsBinary(List<Packet<?>> packets, Parser.EncodeCallback<byte[]> callback) { if (packets.size() == 0) { callback.call(new byte[0]); return; } final ArrayList<byte[]> results = new ArrayList<>(packets.size()); for (Packet packet : packets) { encodePacket(packet, true, packet1 -> { if (packet1 instanceof String) { String encodingLength = String.valueOf(((String) packet1).length()); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)0; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, ((String) packet1).getBytes(StandardCharsets.UTF_8) })); } else { String encodingLength = String.valueOf(((byte[]) packet1).length); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)1; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, (byte[]) packet1 })); } }); } callback.call(Buffer.concat(results.toArray(new byte[results.size()][]))); } private  ServerParser(); static void encodePacket(Packet packet, boolean supportsBinary, Parser.EncodeCallback callback); static void encodePayload(List<Packet<?>> packets, boolean supportsBinary, Parser.EncodeCallback callback); @SuppressWarnings("Duplicates") static void encodePayloadAsBinary(List<Packet<?>> packets, Parser.EncodeCallback<byte[]> callback); static Packet decodePacket(Object data); static void decodePayload(Object data, Parser.DecodePayloadCallback callback); }
ServerParser { @SuppressWarnings("Duplicates") public static void encodePayloadAsBinary(List<Packet<?>> packets, Parser.EncodeCallback<byte[]> callback) { if (packets.size() == 0) { callback.call(new byte[0]); return; } final ArrayList<byte[]> results = new ArrayList<>(packets.size()); for (Packet packet : packets) { encodePacket(packet, true, packet1 -> { if (packet1 instanceof String) { String encodingLength = String.valueOf(((String) packet1).length()); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)0; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, ((String) packet1).getBytes(StandardCharsets.UTF_8) })); } else { String encodingLength = String.valueOf(((byte[]) packet1).length); byte[] sizeBuffer = new byte[encodingLength.length() + 2]; sizeBuffer[0] = (byte)1; for (int i = 0; i < encodingLength.length(); i ++) { sizeBuffer[i + 1] = (byte)Character.getNumericValue(encodingLength.charAt(i)); } sizeBuffer[sizeBuffer.length - 1] = (byte)255; results.add(Buffer.concat(new byte[][] { sizeBuffer, (byte[]) packet1 })); } }); } callback.call(Buffer.concat(results.toArray(new byte[results.size()][]))); } private  ServerParser(); static void encodePacket(Packet packet, boolean supportsBinary, Parser.EncodeCallback callback); static void encodePayload(List<Packet<?>> packets, boolean supportsBinary, Parser.EncodeCallback callback); @SuppressWarnings("Duplicates") static void encodePayloadAsBinary(List<Packet<?>> packets, Parser.EncodeCallback<byte[]> callback); static Packet decodePacket(Object data); static void decodePayload(Object data, Parser.DecodePayloadCallback callback); @SuppressWarnings("WeakerAccess")
    static final int PROTOCOL; }