Hello,

ever since Alex Russell coined the term "comet" for a server push technology
for http, I have been fascinated by the idea. Being dissatisfied with the
responsiveness of my app, I have long wanted to use it in qooxdoo - but
without having the full overhead of including yet another javascript
framework like dojo.  I have finally gotten around to porting the client
javascript code to qooxdoo. The original code is a real mess, unfortunately
- compared to the clean OO architecture of qooxdoo (it works with closures
everywhere - it is hard to digest). The first result of the port can be
found in qooxdoo contrib (cometd). 

https://qooxdoo-contrib.svn.sourceforge.net/svnroot/qooxdoo-contrib/trunk/qooxdoo-contrib/cometd/trunk/

Here are the release notes:

This is a wrapper for the cometd javascript library. 
See http://cometdproject.dojotoolkit.org/

Prerequisites:
-------------
- You need a working cometd server (http://cometd.org/documentation/cometd).
  I have been successful only with the Java/Jetty implementation, neither
  the python/twisted nor the perl server worked for me (on Mac OS X 10.5).
- You need to make sure that the cometd server listens on the same domain
and port
  as the http server that serves the javascript files, otherwise it won't
work
  (because of the dame-domain security policy). This might require that you 
  add a redirection to the Apache server (for example, in my case, I had to
use
  "ProxyPass /cometd http://localhost:8090/cometd-demo-1.0.0rc0/cometd";
  to redirect the requests to /cometd on the Apache instance to the Jetty
  server instance, which is running the cometd server.
  
Getting started..
-----------------
The best place to start is the chat demo shipped with this contribution. The
other
demos provided with the dojo implementation have not been ported yet. The
demo
has to be generated before it can be used.


Todo
----
- The contribution still depends on the dojo base library, this needs to be
ported
  to work with the qooxdoo transport API.
- At the moment, the required libraries need to be manually imported in
index.html.
  Need to find a way to programmatically load them at load time. 

It works pretty well already:

http://n2.nabble.com/file/n3764689/Bild%2B1.png 

Unfortunately, I cannot publish an online demo because I don't want to
install a Jetty server on my public server.

As noted, there is still dojo code in the wrapper - because I don't really
know how to port the transport stuff. In particular, the following code has
to be changed: (source/class/cometd/Client.js:74).

    /*
     * Remap comet AJAX functions to dojo AJAX functions
     * @todo remap to qooxdoo transport
     */
    org.cometd.AJAX.send = function(packet)
    {
        var transportType = packet.transport.getType();
        
        if (transportType == 'long-polling')
        {
            // @todo qx'ify
            var deferred = dojo.rawXhrPost({
                url: packet.url,
                contentType: 'text/json;charset=UTF-8',
                headers: packet.headers,
                postData: packet.body,
                handleAs: 'json',
                load: packet.onSuccess,
                error: function(error) {           
                  packet.onError(error.message, deferred.ioArgs.error); 
                }
            });
            return deferred.ioArgs.xhr;
        }
        else if (transportType == 'callback-polling')
        {
            // @todo qx'ify
            dojo.io.script.get({
                url: packet.url,
                callbackParamName: 'jsonp',
                content: {
                    // In callback-polling, the content must be sent via the
'message' parameter
                    message: packet.body
                },
                load: packet.onSuccess,
                error: function(error) { packet.onError(error.message,
deferred.ioArgs.error); }
            });
            return undefined;
        }
        else
        {
            throw 'Unsupported transport ' + transportType;
        }
    };

Also, I haven't yet found a good was of including the required libraries at
runtime - is there a way of telling the generator to load them in the script
loader?

Ok, if you know how to setup the cometd server, you can check out the demo
on your computer and  enjoy instant synchronization accross windows.

Best,

Christian



-- 
View this message in context: 
http://n2.nabble.com/New-contribution-qooxdoo-cometd-wrapper-tp3764689p3764689.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to