engine.io-server/src/main/java/io/socket/engineio/parser/ServerParser.java
/**
     * Encode an array of packets into a payload for transfer over transport.
     *
     * @param packets Array of packets to encode.
     * @param supportsBinary Whether the transport supports binary encoding.
     * @param callback The callback to be called with the encoded data.
     */
Encode an array of packets into a payload for transfer over transport.
@param packets Array of packets to encode.
@param supportsBinary Whether the transport supports binary encoding.
@param callback The callback to be called with the encoded data.
Encode an array of packets into a payload for transfer over transport . @param packets Array of packets to encode . @param supportsBinary Whether the transport supports binary encoding . @param callback The callback to be called with the encoded data .
public static void encodePayload(Packet[] packets, boolean supportsBinary, Parser.EncodeCallback callback) {
        boolean isBinary = false;
        for (Packet packet : packets) {
            if (packet.data instanceof byte[]) {
                isBinary = true;
                break;
            }
        }
        if (isBinary && supportsBinary) {
            Parser.EncodeCallback<byte[]> _callback = (Parser.EncodeCallback<byte[]>) callback;
            encodePayloadAsBinary(packets, _callback);
            return;
        }
        if (packets.length == 0) {
            callback.call("0:");
            return;
        }
        final StringBuilder result = new StringBuilder();
        for (Packet packet : packets) {
            encodePacket(packet, false, data -> result.append(setLengthHeader((String) data)));
        }
        callback.call(result.toString());
    }
public static void encodePayload ( Packet [ ] packets , boolean supportsBinary , Parser . EncodeCallback callback ) { boolean isBinary = false ; for ( Packet packet : packets ) { if ( packet . data instanceof byte [ ] ) { isBinary = true ; break ; } } if ( isBinary && supportsBinary ) { Parser . EncodeCallback < byte [ ] > _callback = ( Parser . EncodeCallback < byte [ ] > ) callback ; encodePayloadAsBinary ( packets , _callback ) ; return ; } if ( packets . length == 0 ) { callback . call ( "0:" ) ; return ; } final StringBuilder result = new StringBuilder ( ) ; for ( Packet packet : packets ) { encodePacket ( packet , false , data -> result . append ( setLengthHeader ( ( String ) data ) ) ) ; } callback . call ( result . toString ( ) ) ; }
Encode an array of packets into a payload for transfer over transport.
Encode an array of packets into a payload for transfer over transport .