HTML and CSS Reference
In-Depth Information
API overview
API , which stands for Application Programming Interface , is a set of objects, meth-
ods,androutines that letyouinteract with theunderlying layeroffunctionality.Consid-
ering the WebSocket protocol, its API includes the WebSocket primary object, events,
methods, and attributes.
Translating these characteristics into actions, the WebSocket API allows you to con-
nect to a local or remote server, listen for messages, send data, and close the con-
Here is a typical usage of the WebSocket API.
The following illustration shows the typical WebSocket workflow:
Browser support
The WebSocket protocol is a new HTML5 feature, so not every browser supports it
yet. If you ever tried to run WebSocket-specific code on a browser that is not suppor-
ted, nothing would happen. Think of your users: it wouldn't be nice for them to surf on
an unresponsive site. Moreover, you wouldn't like to miss any potential customers!
code. If the browser cannot run the code, you should provide an error message or a
fallback, such as AJAX or Flash-based functionality. There will be more on fallbacks
in Chapter 6 , Error Handling and Fallbacks . I also like providing messages that gently
prompt my users to update their browser.
Search WWH ::

Custom Search