The 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.

An 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".

Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.

Parameters

codeOptional

A numeric value indicating the status code explaining why the connection is being closed. If this parameter is not specified, a default value of 1000 (indicating a normal "transaction complete" closure) is assumed. See the list of status codes on the CloseEvent page for permitted values.

reasonOptional

A human-readable string explaining why the connection is closing. This string must be no longer than 123 UTF-8 characters.

Exceptions thrown

Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.

Parameters

codeOptional

A numeric value indicating the status code explaining why the connection is being closed. If this parameter is not specified, a default value of 1000 (indicating a normal "transaction complete" closure) is assumed. See the list of status codes on the CloseEvent page for permitted values.

reasonOptional

A human-readable string explaining why the connection is closing. This string must be no longer than 123 UTF-8 characters.

Exceptions thrown

Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.

Parameters

codeOptional

A numeric value indicating the status code explaining why the connection is being closed. If this parameter is not specified, a default value of 1000 (indicating a normal "transaction complete" closure) is assumed. See the list of status codes on the CloseEvent page for permitted values.

reasonOptional

A human-readable string explaining why the connection is closing. This string must be no longer than 123 UTF-8 characters.

Parameters

Exceptions thrown

INVALID_STATE_ERR

The connection is not currently OPEN.

SYNTAX_ERR

The data is a string that has unpaired surrogates.

Remarks

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.