WebSocketWriter

class WebSocketWriter(writeChannel: ByteWriteChannel, coroutineContext: CoroutineContext, masking: Boolean, pool: ObjectPool<ByteBuffer>) : CoroutineScope

Class that processes written outgoing Websocket Frame, serializes them and writes the bits into the writeChannel.

Constructors

Link copied to clipboard
fun WebSocketWriter(writeChannel: ByteWriteChannel, coroutineContext: CoroutineContext, masking: Boolean = false, pool: ObjectPool<ByteBuffer> = KtorDefaultPool)

Functions

Link copied to clipboard
fun close()

Closes the message queue

Link copied to clipboard
suspend fun flush()

Ensures all enqueued messages has been written

Link copied to clipboard
suspend fun send(frame: Frame)

Send a frame and write it and all outstanding frames in the queue

Properties

Link copied to clipboard
open override val coroutineContext: CoroutineContext
Link copied to clipboard
var masking: Boolean = false

: whether it will mask serialized frames.

Link copied to clipboard
val outgoing: SendChannel<Frame>

Channel for sending Websocket's Frame that will be serialized and written to writeChannel.

Link copied to clipboard
val pool: ObjectPool<ByteBuffer>

: ByteBuffer pool to be used by this writer