Skip to content

Migrating your Atmosphere 0.x to 0.9 new API

slovdahl edited this page Mar 18, 2013 · 4 revisions

Atmosphere 0.9 API changes

Starting with Atmosphere 0.9, both client and server have backward incompatible API changes. That means an application that was written against version lower than 0.9 may not work. If you are using atmosphere-jersey, you don't need to change anything.

atmosphere-runtime

  • AtmosphereResource, AtmosphereHandler no longer have generics.

    >Before: AtmosphereHandler\<HttpServletRequest,HttpServletResponse\>
    
    >Now: AtmosphereHandler
    

So you need to remove the generic in your AtmosphereHandler to make it work again.

  • HttpServletRequest, HttpServletResponse are now hidden in Atmosphere. So replace all occurrence of those classes with their associated AtmosphereRequest and AtmosphereResponse

  • AtmosphereResource and Broadcaster new fluid API. The return type of many of AtmosphereResource and Broadcaster has been changed to return 'this'. Just recompile your application to avoid linkage exception.

jQuery.atmosphere.js

atmosphere.js has been completely rewritten and has a few backward incompatibilities with the previous version:

  • jQuery.atmosphere.subscribe now return a Response object that can be used to push messages. With previous version you needed to call jQuery.atmosphere.response.push to achieve the same functionality. This is no longer supported and you must use the returned object of jQuery.atmosphere.subscribe.

  • the jQuery.atmosphere.publish(url,callback,request) is no longer supported and replaced by jQuery.atmosphere.publish(request). To inspect the response, attach a function to the request (see next section) named onMessagePublished.

  • callback usage has been deprecated. Instead, jQuery.atmosphere and jQuery.atmosphere.request support function that can be used to receive notification.

    onOpen(response): invoked when the connection get opened
    onClose(response): invoked when the connection get closed
    onReconnect(request,response) invoked when reconnecting. This is where you can change the request.
    onMessage(response): when a message is received
    onError(response): when an unexpected error occurs
    onMessagePublished: when you push a message to the server, the response will be sent to that function
    

All samples have been re-written and can be used to understand the changes. Take a look at the PubSub Client-Server or the infamous Chat Client-Server to realize how simple Atmosphere is!

Step by Step Tutorials

Concepts & Architecture

15 Minutes Tutorial

Advanced Topics

API

Known WebServer Issues

References

External Documentations

githalytics.com alpha

Clone this wiki locally