WebSocket — a bidirectional socket-like network connection
A WebSocket represents a long-lived, bidirectional,
socket-like network connection to a server that supports the
WebSocket protocol. This is a fundamentally different networking
model than the request/response model of HTTP. Create a new
connection with the
send() to send
textual messages to the server, and register a handler for message
events to receive messages from the server. See Web Sockets for further details.
WebSockets are a new Web API and, at the time of this writing, are not supported by all browsers.
creates a new WebSocket object and begins the (asynchronous) process
of establishing a connection to a WebSocket server. The
url argument specifies the server to
connect to and must be an absolute URL that uses the
wss:// URL scheme. The
protocols argument is an array of
subprotocol names. If the argument is specified, it is the client’s
way of telling the server which communication protocols or which
protocol versions it is able to “speak.” The server must choose one
and inform the client as part of the connection process.
protocols may also be specified as a
single string instead of an array: in this case, it is treated as an
array of length 1.
These constants are the values of the
The connection process ...