@Test public void testEncodePacket_base64() { final Packet<byte[]> packet = new Packet<>(Packet.MESSAGE); packet.data = new byte[] { 1, 2, 3, 4, 5 }; ServerParser.encodePacket(packet, false, data -> { String result = runScriptAndGetOutput("src/test/resources/testEncodePacket_base64.js", packet.data, String.class); assertEquals(result, data); }); }
public static void encodePacket(Packet packet, boolean supportsBinary, Parser.EncodeCallback callback) { if (packet.data instanceof byte[]) { encodeByteArray(packet, supportsBinary, callback); } else { String encoded = String.valueOf(packets.get(packet.type)); if (null != packet.data) { encoded += String.valueOf(packet.data); } ((Parser.EncodeCallback<String>) callback).call(encoded); } }
ServerParser { public static void encodePacket(Packet packet, boolean supportsBinary, Parser.EncodeCallback callback) { if (packet.data instanceof byte[]) { encodeByteArray(packet, supportsBinary, callback); } else { String encoded = String.valueOf(packets.get(packet.type)); if (null != packet.data) { encoded += String.valueOf(packet.data); } ((Parser.EncodeCallback<String>) callback).call(encoded); } } }
ServerParser { public static void encodePacket(Packet packet, boolean supportsBinary, Parser.EncodeCallback callback) { if (packet.data instanceof byte[]) { encodeByteArray(packet, supportsBinary, callback); } else { String encoded = String.valueOf(packets.get(packet.type)); if (null != packet.data) { encoded += String.valueOf(packet.data); } ((Parser.EncodeCallback<String>) callback).call(encoded); } } private  ServerParser(); }
ServerParser { public static void encodePacket(Packet packet, boolean supportsBinary, Parser.EncodeCallback callback) { if (packet.data instanceof byte[]) { encodeByteArray(packet, supportsBinary, callback); } else { String encoded = String.valueOf(packets.get(packet.type)); if (null != packet.data) { encoded += String.valueOf(packet.data); } ((Parser.EncodeCallback<String>) callback).call(encoded); } } 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 { public static void encodePacket(Packet packet, boolean supportsBinary, Parser.EncodeCallback callback) { if (packet.data instanceof byte[]) { encodeByteArray(packet, supportsBinary, callback); } else { String encoded = String.valueOf(packets.get(packet.type)); if (null != packet.data) { encoded += String.valueOf(packet.data); } ((Parser.EncodeCallback<String>) callback).call(encoded); } } 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; }