HTML and CSS Reference
In-Depth Information
WebSocket, Fallback Support, and Auto-Reconnect
In Chapter 1 we demonstrated how great WebSocket technology is, but that there is still an unfortunate need to offer
fallbacks for older browsers, or where tricky networks are involved. It should therefore come as a relief that Pusher
also deals with fallbacks for older browsers. Its JavaScript library chooses the most appropriate connection method
based on the browser runtime and the network conditions. The library also detects dropped connections and will
automatically reconnect for you.
The library creates a connection between the user's browser and the Pusher service so that the instant new data
is available it can be published and pushed to them. You can also publish information directly from the client. We'll
dig deeper into the functionality that's available as we work our way through this chapter.
Other Client Libraries
Although the WebSocket specification now falls under the HTML5 umbrella, it's important to remember that it's
a specification of a protocol. What this means is that any technology that can make a TCP connection can also
make a WebSocket connection. Pusher takes advantage of this and also offers client libraries in a number of other
technologies, including Objective-C for iOS development, Java for Android and desktop development, ActionScript
for Flash, and C# for general .NET and Silverlight runtimes.
No hosted service is complete without a REST API, and Pusher is no different. 1 The REST API is primarily used for
publishing data, but also offers functionality to query the state of your application within Pusher. Offering a REST API
means that any technology that can make an HTTP request can use this API.
Server Libraries
Since the REST API requires authentication and has some potentially complex requirements, there have been a
number of server libraries developed to make executing requests to the API easier. Since all you need to do to make
a call to a REST API is make an HTTP request, it's no surprise that the number of libraries available is very long. 2
The most commonly used libraries include PHP, Ruby, .NET, Python, Node.js, and Java.
Developer Tools
Another increasingly useful feature of hosted services is some form of developer tooling that increases the ease at
which development can take place. This is achieved by exposing the internal workings and logging information
available to the service. In Pusher's case, this means exposing information such as connections and data flow related
to the application that you are building. We'll use these tools as we build our application.
Documentation is essential to any technology and even more so to a hosted service, which can be looked at as a black
box—it's not like you can go digging around in the source code for all the components of a hosted service to find out
what's going on—even if they do open source some of them or use existing open source ones.
1 REST purists may argue that Pusher's REST API isn't strictly RESTful. We could have instead listed this as a Web or HTTP API.
Search WWH ::

Custom Search