close

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

Sends a close frame with the specified reason. May suspend if the 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?)

Deprecated

Close with reason or terminate instead.

Closes with the reason depending on cause or normally if the cause is null.