HTML and CSS Reference
In-Depth Information
Table 3-5. WebSocket Close Code Ranges
Code
Description
When to Use this Code
0-999
Prohibited
Codes below 1000 are invalid and can
never be used for any purpose.
1000-2999
Reserved
These codes are reserved for use in
extensions and revised versions of the
WebSocket protocol itself. Use these codes
as the standard prescribes. See Table 3-4.
3000-3999
Registration Required
These codes are intended for use
by “libraries, frameworks, and
applications.” These codes should be
publicly registered with IANA (Internet
Assigned Numbers Authority).
4000-4999
Private
Use these codes for custom purposes
in your applications. Because they are
not registered, do not expect them to be
widely understood by other WebSocket
software.
Support for Other Protocols
The WebSocket Protocol supports higher-level protocols and protocol negotiation.
Paradoxically, RFC 6455 refers to protocols you can use with WebSocket as “subprotocols,”
even though they are higher-level, fully formed protocols. As we mentioned in Chapter 2,
throughout this topic, we'll generally refer to protocols that you can use with WebSocket
simply as “protocols” to avoid confusion.
In Chapter 2, we explained how to negotiate higher-layer protocols with the
WebSocket API. At the network level, these protocols are negotiated using the
Sec-WebSocket-Protocol header. Protocol names are header values sent from the client
in the initial upgrade request:
Sec-WebSocket-Protocol: com.kaazing.echo, example.protocol.name
This header indicates that the client can use either protocol ( com.kaazing.echo or
example.protocol.name ) and the server can choose which protocol to use. If you send
this header in an upgrade request to ws://echo.websocket.org , the server response will
include the following header:
Sec-WebSocket-Protocol: com.kaazing.echo
This response indicates that the server has elected to speak the com.kaazing.echo
protocol. Selecting a protocol does not change the syntax of the WebSocket Protocol
itself. Instead, these protocols are layered on top of the WebSocket Protocol to provide
higher-level semantics for frameworks and applications. We will examine three different
use cases of layering widely used, standards-based protocols on top of WebSocket in the
subsequent chapters.
 
 
Search WWH ::




Custom Search