目录

WebSocket

WebSocket APIs function in the same way as standard HTML5 APIs.

Definition

API

Description

var webSocket = new WebSocket(url, [protocol] );

Creates a WebSocket object.

close(code, reason)

Closes a WebSocket connection.

send(data)

Sends data.

webSocket.binaryType

Explicitly specifies the type of the received binary data. The value can be blob or arraybuffer.

webSocket.bufferedAmount

Obtains the number of remaining bytes to be sent.

webSocket.extensions

Obtains the extensions supported by the server.

webSocket.onclose = callback

Listens for WebSocket connection closing events.

webSocket.onopen = callback

Listens for WebSocket connection opening events.

webSocket.onmessage = callback

Listens for events that messages are received through the WebSocket connection from the server.

webSocket.onerror = callback(errMsg)

Listens for WebSocket error events.

webSocket.protocol

Returns the protocol used by the instance.

webSocket.readyState

Returns the current status of the instance.

webSocket.url

Returns the URL of the connection.

[h2]var webSocket = new WebSocket(url, [protocol] );

[h2]close(code, reason)

[h2]send(data)

[h2]webSocket.binaryType

[h2]webSocket.bufferedAmount

[h2]webSocket.extensions

[h2]webSocket.onclose = callback

[h2]webSocket.onopen = callback

[h2]webSocket.onmessage = callback

[h2]webSocket.onerror = callback(errMsg)

[h2]webSocket.protocol

[h2]webSocket.readyState

[h2]webSocket.url