The WebSocket(url, protocols) constructor takes one or two arguments. The first argument,
url, specifies the URL to which to connect. The second, protocols, if present, is either a string or an array of strings. If it is a
string, it is equivalent to an array consisting of just that string; if it is omitted, it is
equivalent to the empty array.
Properties |
const unsigned short | - CLOSED = 3
- The connection has been closed or could not be opened.
|
const unsigned short | - CLOSING = 2
- The connection is going through the closing handshake, or the close() method has been invoked.
|
const unsigned short | - CONNECTING = 0
- The connection has not yet been established.
|
const unsigned short | - OPEN = 1
- The WebSocket connection is established and communication is possible.
|
BinaryType | - binaryType
- When a WebSocket object is created, its binaryType IDL attribute must be set to the
string "blob". On getting, it must return the last value it was set to. On
setting, the user agent must set the IDL attribute to the new value.
|
unsigned long | - bufferedAmount
- The bufferedAmount attribute must
return the number of bytes of application data (UTF-8 text and binary data) that have been queued
using send() but that, as of the last time the event
loop reached step 1, had not yet been
transmitted to the network.
|
DOMString | - extensions
- The extensions attribute must
initially return the empty string. After the WebSocket connection is established, its value
might change, as defined below.
|
EventHandler | onclose |
EventHandler | onerror |
EventHandler | onmessage |
EventHandler | onopen |
DOMString | - protocol
- The protocol attribute must initially
return the empty string. After the WebSocket connection is established, its value might
change, as defined below.
|
unsigned short | - readyState
- The readyState attribute represents
the state of the connection.
|
DOMString | - url
- The url attribute must return the result of
resolving the URL that was passed to the
constructor, with the URL character encoding set to UTF-8. (It doesn't matter what it is resolved
relative to, since we already know it is an absolute URL.)
|