|
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/. |
|
5 * |
|
6 * The origin of this IDL file is |
|
7 * http://www.whatwg.org/html/#network |
|
8 * |
|
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. |
|
11 */ |
|
12 |
|
13 enum BinaryType { "blob", "arraybuffer" }; |
|
14 |
|
15 [Func="mozilla::dom::WebSocket::PrefEnabled", |
|
16 Constructor(DOMString url), |
|
17 Constructor(DOMString url, DOMString protocols), |
|
18 Constructor(DOMString url, sequence<DOMString> protocols)] |
|
19 interface WebSocket : EventTarget { |
|
20 |
|
21 readonly attribute DOMString url; |
|
22 |
|
23 // ready state |
|
24 const unsigned short CONNECTING = 0; |
|
25 const unsigned short OPEN = 1; |
|
26 const unsigned short CLOSING = 2; |
|
27 const unsigned short CLOSED = 3; |
|
28 |
|
29 readonly attribute unsigned short readyState; |
|
30 |
|
31 readonly attribute unsigned long bufferedAmount; |
|
32 |
|
33 // networking |
|
34 |
|
35 attribute EventHandler onopen; |
|
36 |
|
37 attribute EventHandler onerror; |
|
38 |
|
39 attribute EventHandler onclose; |
|
40 |
|
41 readonly attribute DOMString extensions; |
|
42 |
|
43 readonly attribute DOMString protocol; |
|
44 |
|
45 [Throws] |
|
46 void close([Clamp] optional unsigned short code, optional DOMString reason); |
|
47 |
|
48 // messaging |
|
49 |
|
50 attribute EventHandler onmessage; |
|
51 |
|
52 attribute BinaryType binaryType; |
|
53 |
|
54 [Throws] |
|
55 void send(DOMString data); |
|
56 |
|
57 [Throws] |
|
58 void send(Blob data); |
|
59 |
|
60 [Throws] |
|
61 void send(ArrayBuffer data); |
|
62 |
|
63 [Throws] |
|
64 void send(ArrayBufferView data); |
|
65 }; |