1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://www.whatwg.org/html/#network
9 * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA.
10 * You are granted a license to use, reproduce and create derivative works of this document.
13 enum BinaryType { "blob", "arraybuffer" };
15 [Exposed=(Window,Worker)]
16 interface WebSocket : EventTarget {
18 constructor(DOMString url, optional (DOMString or sequence<DOMString>) protocols = []);
20 readonly attribute DOMString url;
23 const unsigned short CONNECTING = 0;
24 const unsigned short OPEN = 1;
25 const unsigned short CLOSING = 2;
26 const unsigned short CLOSED = 3;
28 readonly attribute unsigned short readyState;
30 readonly attribute unsigned long long bufferedAmount;
34 attribute EventHandler onopen;
36 attribute EventHandler onerror;
38 attribute EventHandler onclose;
40 readonly attribute DOMString extensions;
42 readonly attribute DOMString protocol;
45 undefined close(optional [Clamp] unsigned short code, optional DOMString reason);
49 attribute EventHandler onmessage;
51 attribute BinaryType binaryType;
54 undefined send(DOMString data);
57 undefined send(Blob data);
60 undefined send(ArrayBuffer data);
63 undefined send(ArrayBufferView data);
66 // Support for creating server-side chrome-only WebSocket. Used in
67 // devtools remote debugging server.
68 interface nsITransportProvider;
70 partial interface WebSocket {
71 [ChromeOnly, NewObject, Throws]
72 static WebSocket createServerWebSocket(DOMString url,
73 sequence<DOMString> protocols,
74 nsITransportProvider transportProvider,
75 DOMString negotiatedExtensions);