The OpenD Programming Language

WebSocket.CloseEvent

Arguments for the close event. The code and reason are provided from the close message on the websocket, if they are present. The spec says code 1000 indicates a normal, default reason close, but reserves the code range from 3000-5000 for future definition; the 3000s can be registered with IANA and the 4000's are application private use. The reason should be user readable, but not displayed to the end user. wasClean is true if the server actually sent a close event, false if it just disconnected.

The reason argument references a temporary buffer and there's no guarantee it will remain valid once your callback returns. It may be freed and will very likely be overwritten. If you want to keep the reason beyond the callback, make sure you .idup it.
class WebSocket
static
struct CloseEvent {
ushort code;
const(char)[] reason;
bool wasClean;
string extendedErrorInformationUnstable;
}

Members

Enums

StandardCloseCodes
enum StandardCloseCodes

See https://www.rfc-editor.org/rfc/rfc6455#section-7.4.1 for details.

Meta

History

Added March 19, 2023 (dub v11.0).