Skip to content

WebSocket

Generated from idl/websockets.webidl when the site was built at 7aa23e2.

WebSocket is an interface in idl/websockets.webidl, inheriting EventTarget, exposed in Window, Worker. What it does is on MDN; this page says what niso has of it.

Text and binary frames reach native code in the C API’s own types, a string or an ArrayBuffer, through MessageEvent.data’s native form (DECISIONS, Web platform APIs).

The web features its members belong to, each with its Baseline status on the web and how much of the feature’s WPT suite passes in niso (see Web platform support).

Feature On the web In niso Members
WebSockets Widely available Partial 88% 756 of 857 subtests pass 14
constructor
constructor(USVString url, optional (DOMString or sequence<DOMString>) protocols = []);
int32_t niso_web_socket_new(niso_dom* dom, const char* url, size_t url_len, const niso_str* protocols, size_t protocols_len, niso_handle* out);

Known bug: protocols that repeat in another case don’t throw SyntaxError (docs/wpt.md, Bugs the suite found).

attribute
readonly attribute USVString url;
int32_t niso_web_socket_get_url(niso_dom* dom, niso_handle self, niso_str* out);
const
const unsigned short CONNECTING = 0;
const
const unsigned short OPEN = 1;
const
const unsigned short CLOSING = 2;
const
const unsigned short CLOSED = 3;
attribute
readonly attribute unsigned short readyState;
int32_t niso_web_socket_get_ready_state(niso_dom* dom, niso_handle self, uint16_t* out);
attribute
readonly attribute unsigned long long bufferedAmount;
int32_t niso_web_socket_get_buffered_amount(niso_dom* dom, niso_handle self, uint64_t* out);
attribute
attribute EventHandler onopen;
int32_t niso_web_socket_get_onopen(niso_dom* dom, niso_handle self, void** out);
int32_t niso_web_socket_set_onopen(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute
attribute EventHandler onerror;
int32_t niso_web_socket_get_onerror(niso_dom* dom, niso_handle self, void** out);
int32_t niso_web_socket_set_onerror(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute
attribute EventHandler onclose;
int32_t niso_web_socket_get_onclose(niso_dom* dom, niso_handle self, void** out);
int32_t niso_web_socket_set_onclose(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute
readonly attribute DOMString extensions;
int32_t niso_web_socket_get_extensions(niso_dom* dom, niso_handle self, niso_str* out);
attribute
readonly attribute DOMString protocol;
int32_t niso_web_socket_get_protocol(niso_dom* dom, niso_handle self, niso_str* out);
operation
undefined close(optional [Clamp] unsigned short code, optional USVString reason);
int32_t niso_web_socket_close(niso_dom* dom, niso_handle self, bool has_code, uint16_t code, const char* reason, size_t reason_len);
attribute
attribute EventHandler onmessage;
int32_t niso_web_socket_get_onmessage(niso_dom* dom, niso_handle self, void** out);
int32_t niso_web_socket_set_onmessage(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute
attribute BinaryType binaryType;
int32_t niso_web_socket_get_binary_type(niso_dom* dom, niso_handle self, niso_str* out);
int32_t niso_web_socket_set_binary_type(niso_dom* dom, niso_handle self, const char* value, size_t value_len);
operation
undefined send((BufferSource or USVString) data);
int32_t niso_web_socket_send(niso_dom* dom, niso_handle self, const niso_buffer_or_string* data);

Members the web has, by the BCD keys web-features 3.45.0 lists, that idl/ doesn’t declare. The list is partial: web-features lists only the keys it maps to a feature.

  • protocol_rfc_6455 (WebSockets)
  • worker_support (WebSockets)