WebSocket.close

Closes the connection, sending a graceful teardown message to the other side. If you provide no arguments, it sends code 1000, normal closure. If you provide a code, you should also provide a short reason string.

  1. void close()
    class WebSocket
    void
    close
    ()
  2. void close(int code, string reason)

See Also

Meta

History

The default code was changed to 1000 on January 9, 2023. Previously it was 0, but also ignored anyway.

On May 11, 2024, the optional arguments were changed to overloads since if you provide a code, you should also provide a reason.