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 13enum BinaryType { "blob", "arraybuffer" }; 14 15[Exposed=(Window,Worker)] 16interface WebSocket : EventTarget { 17 [Throws] 18 constructor(DOMString url, optional (DOMString or sequence<DOMString>) protocols = []); 19 20 readonly attribute DOMString url; 21 22 // ready state 23 const unsigned short CONNECTING = 0; 24 const unsigned short OPEN = 1; 25 const unsigned short CLOSING = 2; 26 const unsigned short CLOSED = 3; 27 28 readonly attribute unsigned short readyState; 29 30 readonly attribute unsigned long long bufferedAmount; 31 32 // networking 33 34 attribute EventHandler onopen; 35 36 attribute EventHandler onerror; 37 38 attribute EventHandler onclose; 39 40 readonly attribute DOMString extensions; 41 42 readonly attribute DOMString protocol; 43 44 [Throws] 45 void close(optional [Clamp] unsigned short code, optional DOMString reason); 46 47 // messaging 48 49 attribute EventHandler onmessage; 50 51 attribute BinaryType binaryType; 52 53 [Throws] 54 void send(DOMString data); 55 56 [Throws] 57 void send(Blob data); 58 59 [Throws] 60 void send(ArrayBuffer data); 61 62 [Throws] 63 void send(ArrayBufferView data); 64}; 65 66// Support for creating server-side chrome-only WebSocket. Used in 67// devtools remote debugging server. 68interface nsITransportProvider; 69 70partial interface WebSocket { 71 [ChromeOnly, NewObject, Throws] 72 static WebSocket createServerWebSocket(DOMString url, 73 sequence<DOMString> protocols, 74 nsITransportProvider transportProvider, 75 DOMString negotiatedExtensions); 76}; 77