flush

fun flush()

Flushes all pending messages in the WebSocket session.

This method launches a coroutine that suspends until all previously sent messages are written to the network.

  • It can be called at any time, even after calling disconnect.

  • If the connection is already terminated, it may return immediately.

  • This does not guarantee that the remote peer has received the messages.

  • May throw exceptions or be cancelled if the session fails during the flush.

Example usage:

wsManager.flush()