close

suspend fun WebSocketSession.close(
    reason: CloseReason = CloseReason(CloseReason.Codes.NORMAL, "")
): Unit

Send a close frame with the specified reason. May suspend if outgoing channel is full. The specified reason could be ignored if there was already close frame sent (for example in reply to a peer close frame). It also may do nothing when a session or an outgoing channel is already closed due to any reason.

suspend fun WebSocketSession.close(cause: Throwable?): Unit

Deprecated: Close with reason or terminate instead.

Closes with reason depending on cause or normally if cause is null. This is going to be removed. Close with a particular reason or terminate instead.