HTML and CSS Reference
In-Depth Information
Pusher . log = function ( msg ) {
if ( window . console && window . console . log ) {
window . console . log ( new Date (). getTime () + ': ' + msg );
}
};
The code above checks to make sure the console and log function is available - it's not in
older browsers - and then logs the messages along with a timestamp to the JavaScript
console. This can be incredibly handy in tracking down problems.
CHECK CONNECTIVITY
Any good real-time technology will maintain a persistent connection between the client (web
browser) and the Web server or service. Sometimes the client will lose connectivity and when
the client isn't connected to the Internet the real-time functionality won't work. This can happen
a lot with applications running on mobile devices which rely on mobile networks. So, if your
application relies on that connectivity and functionality then it's important to deal with scenarios
where the client isn't connected. This might be by displaying a message to tell the user they
are offline or you might want to implement some alternative functionality.
The Pusher JavaScript library exposes connectivity state via the pusher.connection object,
36
which we briefly saw earlier when fetching the socket_id . Binding to state changes and
implementing your required functionality is quite simple as it follows the same mechanism as
binding to events on channels:
 
Search WWH ::




Custom Search