okhttp / okhttp3 / WebSocket / close

close

abstract fun close(code: Int, reason: String?): Boolean

Attempts to initiate a graceful shutdown of this web socket. Any already-enqueued messages will be transmitted before the close message is sent but subsequent calls to send will return false and their messages will not be enqueued.

This returns true if a graceful shutdown was initiated by this call. It returns false if a graceful shutdown was already underway or if the web socket is already closed or canceled.

Parameters

code - Status code as defined by Section 7.4 of RFC 6455.

reason - Reason for shutting down or null.

Exceptions

IllegalArgumentException - if code is invalid.