onTextMessage

suspend fun onTextMessage(text: String, isLast: Boolean = true)(source)

Callback for text messages (potentially partial frames).

Use this overload when the data of the frame can be converted without copy into a String for processing. If the data is provided as a reusable (char) buffer that must be consumed/copied, use the other overload to write directly to the Sink buffer to avoid copying data around.

If isLast is true, the web socket frame is considered complete and the full (aggregated) message is sent to the incomingFrames flow as a WebSocketFrame.Text frame. Otherwise, the message is simply appended to a buffer and nothing happens in the incomingFrames flow. More partial messages are expected in this case.


suspend fun onTextMessage(isLast: Boolean = true, writeData: Sink.() -> Unit)(source)

Callback for text messages (potentially partial frames).

Use this overload when the data of the frame is provided as a reusable buffer that must be consumed/copied, and use writeData to transfer data from the received buffer into this adapter's buffer. If the data of the frame can be converted without copy into a String for processing, use the other overload taking a String as parameter.

If isLast is true, the web socket frame is considered complete and the full (aggregated) message is sent to the incomingFrames flow as a WebSocketFrame.Text frame. Otherwise, the message is simply appended to a buffer and nothing happens in the incomingFrames flow. More partial messages are expected in this case.