extern class js.html.WebSocketextends EventTargetAvailable in js

This is an experimental feature
Because this feature is still in development in some browsers, check the compatibility table for the proper prefixes to use in various browsers.

The WebSocket object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.

Documentation for this class was provided by MDN.
var URL(default,null) : String var binaryType : StringA string indicating the type of binary data being transmitted by the connection. This should be either "blob" if DOM Blob  objects are being used or "arraybuffer" if ArrayBuffer objects are being used. var bufferedAmount(default,null) : IntThe number of bytes of data that have been queued using calls to but not yet transmitted to the network. This value does not reset to zero when the connection is closed; if you keep calling , this will continue to climb. Read only. var extensions(default,null) : StringThe extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection. var onclose : EventListenerAn event listener to be called when the WebSocket connection's readyState changes to CLOSED. The listener receives a CloseEvent named "close". var onerror : EventListenerAn event listener to be called when an error occurs. This is a simple event named "error". var onmessage : EventListenerAn event listener to be called when a message is received from the server. The listener receives a MessageEvent named "message". var onopen : EventListenerAn event listener to be called when the WebSocket connection's readyState changes to OPEN; this indicates that the connection is ready to send and receive data. The event is a simple one with the name "open". var protocol(default,null) : StringA string indicating the name of the sub-protocol the server selected; this will be one of the strings specified in the protocols parameter when creating the WebSocket object. var readyState(default,null) : IntThe current state of the connection; this is one of the Ready state constants. Read only. var url(default,null) : StringThe URL as resolved by the constructor. This is always an absolute URL. Read only. function new( ?arg0 : Dynamic ) : Void function close( ?code : Int, ?reason : String ) : Void function send( data : String ) : Bool

Transmits data to the server over the WebSocket connection.

A text string to send to the server.
Exceptions thrown
The connection is not currently OPEN.
The data is a string that has unpaired surrogates.

Gecko 6.0 note
(Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3)

Gecko's implementation of the send() method differs somewhat from the specification in Gecko 6.0; Gecko returns a boolean indicating whether or not the connection is still open (and, by extension, that the data was successfully queued or transmitted); this is corrected in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5) . In addition, at this time, Gecko does not support ArrayBuffer or Blob data types.

Throws DOMException.
static inline var CLOSED : IntThe connection is closed or couldn't be opened. static inline var CLOSING : IntThe connection is in the process of closing. static inline var CONNECTING : IntThe connection is not yet open. static inline var OPEN : IntThe connection is open and ready to communicate.
version #18374, modified 2013-05-01 11:58:58 by api
0 comment