cometd/cometd — pull request #7 by rbackhouse (2012-03-28 15:20:15+00:00)
Title: Support for AMD Loaders

The OpenCoweb project (http://opencoweb.org/) has been using the cometd javascript in an AMD environment for a while now. We have been wrapping the code with a "define" call and it has been working fine.

I saw in http://bugs.cometd.org/browse/COMETD-336 that there is plan to add AMD support. I thought I would put together a patch that enables AMD support while keeping backward compatibility.

I have also strengthened the dojo provide check to make it more robust. That path should only be called when Dojo is being run in sync mode.

The AMD define call is only made if the AMD check passes :

if (typeof define === "function" && define.amd)

I have also added AMD support to all the extensions too.

I should note that when I forked the cometd repo one of the tests was failing :

TEST-org.cometd.javascript.CometDWebSocketConnectTimeoutTest

I think it might be due to the fix for COMETD-343 as all the tests were passing about a week ago.

My changes do not appear to break anything else