CloseEvent Class

The event fired when a WebSocket is closed (https://websockets.spec.whatwg.org/#the-closeevent-interface).

public sealed class CloseEvent : Event
Inheritance
Event CloseEvent

Constructors

NameDescription
CloseEvent(string, CloseEventInit?)Creates a close event with the given type and initialization dictionary.

CloseEvent(string, CloseEventInit?)

CloseEvent.cs

Creates a close event with the given type and initialization dictionary.

public CloseEvent(string type, CloseEventInit? eventInitDict = null)

Properties

NameDescription
CodeGets the WebSocket connection close code (https://www.rfc-editor.org/rfc/rfc6455#section-7.1.5): the status code of the Close frame received from the server, 1005 when it has no status code, or 1006 when no Close frame was received (e.g. the connection failed).
ReasonGets the WebSocket connection close reason: the reason of the Close frame received from the server, or the empty string.
WasCleanGets whether the connection closed cleanly: the closing handshake completed.

Gets the WebSocket connection close code (https://www.rfc-editor.org/rfc/rfc6455#section-7.1.5): the status code of the Close frame received from the server, 1005 when it has no status code, or 1006 when no Close frame was received (e.g. the connection failed).

public ushort Code { get; }

Gets the WebSocket connection close reason: the reason of the Close frame received from the server, or the empty string.

public string Reason { get; }

Gets whether the connection closed cleanly: the closing handshake completed.

public bool WasClean { get; }