websockets.idl (1514B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: WebSockets Standard (https://websockets.spec.whatwg.org/) 5 6 enum BinaryType { "blob", "arraybuffer" }; 7 8 [Exposed=(Window,Worker)] 9 interface WebSocket : EventTarget { 10 constructor(USVString url, optional (DOMString or sequence<DOMString>) protocols = []); 11 readonly attribute USVString url; 12 13 // ready state 14 const unsigned short CONNECTING = 0; 15 const unsigned short OPEN = 1; 16 const unsigned short CLOSING = 2; 17 const unsigned short CLOSED = 3; 18 readonly attribute unsigned short readyState; 19 readonly attribute unsigned long long bufferedAmount; 20 21 // networking 22 attribute EventHandler onopen; 23 attribute EventHandler onerror; 24 attribute EventHandler onclose; 25 readonly attribute DOMString extensions; 26 readonly attribute DOMString protocol; 27 undefined close(optional [Clamp] unsigned short code, optional USVString reason); 28 29 // messaging 30 attribute EventHandler onmessage; 31 attribute BinaryType binaryType; 32 undefined send((BufferSource or Blob or USVString) data); 33 }; 34 35 [Exposed=(Window,Worker)] 36 interface CloseEvent : Event { 37 constructor(DOMString type, optional CloseEventInit eventInitDict = {}); 38 39 readonly attribute boolean wasClean; 40 readonly attribute unsigned short code; 41 readonly attribute USVString reason; 42 }; 43 44 dictionary CloseEventInit : EventInit { 45 boolean wasClean = false; 46 unsigned short code = 0; 47 USVString reason = ""; 48 };