HttpChannels.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.cometd.HttpChannels"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.cometd.HttpChannels"] = true;
  8. dojo.provide("dojox.cometd.HttpChannels");
  9. dojo.require("dojox.io.httpParse");
  10. dojo.require("dojox.cometd.RestChannels");
  11. // Note that cometd _base is _not_ required, this can run standalone, but ifyou want
  12. // cometd functionality, you must explicitly load/require it elsewhere, and cometd._base
  13. // MUST be loaded prior to HttpChannels ifyou use it.
  14. // summary:
  15. // HttpChannels - An HTTP Based approach to Comet transport with full HTTP messaging
  16. // semantics including REST. HttpChannels is exactly the same as RestChannels, loading HttpChannels simply ensures that http parsing
  17. // capabilities are present for application/http messages
  18. // description:
  19. // This can be used:
  20. // 1. As a cometd transport
  21. // 2. As an enhancement for the REST RPC service, to enable "live" data (real-time updates directly alter the data in indexes)
  22. // 2a. With the JsonRestStore (which is driven by the REST RPC service), so this dojo.data has real-time data. Updates can be heard through the dojo.data notification API.
  23. // 3. As a standalone transport. To use it as a standalone transport looks like this:
  24. // | dojox.cometd.HttpChannels.open();
  25. // | dojox.cometd.HttpChannels.get("/myResource",{callback:function(){
  26. // | // this is called when the resource is first retrieved and any time the
  27. // | // resource is changed in the future. This provides a means for retrieving a
  28. // | // resource and subscribing to it in a single request
  29. // | });
  30. // | dojox.cometd.HttpChannels.subscribe("/anotherResource",{callback:function(){
  31. // | // this is called when the resource is changed in the future
  32. // | });
  33. // Channels HTTP can be configured to a different delays:
  34. // | dojox.cometd.HttpChannels.autoReconnectTime = 60000; // reconnect after one minute
  35. //
  36. dojox.cometd.HttpChannels = dojox.cometd.RestChannels;
  37. }