HTML and CSS Reference
In-Depth Information
day, with peaks during certain times of the day, and with heavy interaction by users
requesting, sharing, and posting videos. Each scenario is ideal for WebSocket, and each
has different deployment requirements.
In the earlier chapters of this topic, you also learned about different ways you can use
standard protocols over WebSocket. One of the choices you can make, which you learned
in Chapter 4, is that you can choose to enable WebSocket in your server (for example, you
could enable your XMPP chat server to speak WebSocket) or choose to use a gateway that
sits between your TCP-based server and your clients, but enables you to layer standard
protocols over WebSocket to take advantage of the full-duplex connection. In each of
these cases, you may need to think about how your WebSocket-enabled back-end server
or your WebSocket gateway will handle a variety of client connections.
The difference between application deployment and WebSocket application
deployment is not vast, but there are some areas to think about when deploying your
WebSocket application.
WebSocket Emulation and Fallback
While modern browsers natively support WebSocket, there are still many older versions
of browsers without native WebSocket support that are widely used, many of which are
in corporate environments or under business requirements that strictly control browsers
and versions. As a developer, you often do not have control over the type of browser used
to access your application, but you still want to accommodate as wide an audience as
possible. There are ways to achieve “emulation” of WebSocket's capabilities by using
other communication strategies between cooperating client libraries and servers. There is
also the option to fall back to another communication technique as a last resort.
Plugins
One way you can establish full-duplex communication is with plugins. A common plugin
is Adobe Flash, which lets you open a TCP socket. While Flash tends to be installed in
most desktop browsers, if it is not present, users must explicitly download it, which can
be intrusive to the user experience. Using a plugin for communication also impacts the
performance of your application due to the expensive communication between Flash
and your application code. Even worse, using Flash sockets can cause your application to
hang for up to three seconds while connecting. Also, keep in mind that Adobe Flash is not
fully supported in the popular iOS, Android, and Windows RT environments. This lack
of support means plugin-based fallback strategies are becoming less and less viable as
browsers continue to move away from plugin-based extensibility.
Polyfills
A viable alternative to plugins is a polyfill, which is a library that implements a standard
API using legacy browser features. Polyfills allow developers to target new web standards
while creating applications and still reach users with older browsers. A number of polyfills
exist for a variety of HTML5 features, including graphics, forms, and databases. Polyfills
 
Search WWH ::




Custom Search