encodeWsFrame

fun <T> encodeWsFrame(packet: EngineIOPacket<T>, serializePayload: (T) -> String): String(source)

Encodes the given EngineIOPacket to a string, which can be used as a text web socket frame body.

If this packet is a EngineIOPacket.Message packet, the payload is serialized using the provided serializePayload function.

This is meant to be used in web socket mode, where each web socket frame contains a single Engine.IO packet. Binary packets are not allowed because the raw data should just be sent directly as a binary web socket frame.


Encodes the given EngineIOPacket to a ByteString, which can be used as a binary web socket frame body.

This is meant to be used in web socket mode, where the raw data is sent directly as a binary web socket frame. Binary data is only encoded as base64 when using the HTTP long-polling mode (see encodeHttpBatch).