| // Copyright 2017 Google Inc. All Rights Reserved. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| // https://www.w3.org/TR/websockets/#the-websocket-interface |
| |
| [ |
| Constructor(DOMString url, optional DOMString protocols), |
| ConstructorCallWith=EnvironmentSettings, |
| RaisesException=Constructor |
| ] |
| interface WebSocket : EventTarget { |
| readonly attribute DOMString url; |
| |
| // ready state |
| const unsigned short CONNECTING = 0; |
| const unsigned short OPEN = 1; |
| const unsigned short CLOSING = 2; |
| const unsigned short CLOSED = 3; |
| readonly attribute unsigned short readyState; |
| readonly attribute unsigned long bufferedAmount; |
| |
| // networking |
| attribute EventHandler onopen; |
| attribute EventHandler onerror; |
| attribute EventHandler onclose; |
| readonly attribute DOMString extensions; |
| readonly attribute DOMString protocol; |
| [RaisesException] void close([Clamp] optional unsigned short code, |
| optional DOMString reason); |
| |
| // messaging |
| attribute EventHandler onmessage; |
| [RaisesException] attribute DOMString binaryType; |
| [RaisesException] void send(DOMString data); |
| [RaisesException] void send(ArrayBuffer data); |
| |
| // Blob is not currently supported in Cobalt. |
| // [RaisesException] void send(Blob data); |
| // ArrayBufferViews translation is not well supported in Cobalt. |
| // [RaisesException] void send(ArrayBufferView data); |
| }; |
| |
| typedef EventListener? EventHandler; |