disconnect

Closes the current WebSocket connection gracefully.

This method launches a coroutine that sends a WebSocket close frame to the server.

  • If the outgoing channel is full, this operation may suspend until space is available.

  • If a close frame was already sent (for example, in response to the server closing the connection), the specified reason may be ignored.

  • If the session or outgoing channel is already closed, this method will do nothing.

After closing, the internal session reference is cleared.

Example usage:

wsManager.disconnect()