summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/cometd/ack.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/dojo/dojox/cometd/ack.js')
-rw-r--r--js/dojo/dojox/cometd/ack.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/js/dojo/dojox/cometd/ack.js b/js/dojo/dojox/cometd/ack.js
new file mode 100644
index 0000000..95e7617
--- /dev/null
+++ b/js/dojo/dojox/cometd/ack.js
@@ -0,0 +1,55 @@
+//>>built
+// wrapped by build app
+define("dojox/cometd/ack", ["dijit","dojo","dojox","dojo/require!dojox/cometd/_base"], function(dijit,dojo,dojox){
+dojo.provide("dojox.cometd.ack");
+dojo.require("dojox.cometd._base");
+
+/*
+ * This file provides the dojox cometd ack extension which
+ * acknowledges the messages received in /meta/connect responses.
+ * Each meta/connect is sent with the id of the last successful meta/connect
+ * received. The server uses this information to manage a queue of unacknowleged
+ * messages.
+ *
+ * To use, add dojo.require("dojox.cometd.ack"); and if the handshake will be sent
+ * with ext:{ack:true}. If the server supports the same extension, then the
+ * mechanism will be initialized. The dojox.cometd.ackEnabled field may also be
+ * used to optionally enable/disable the extension before init of cometd.
+ *
+ */
+dojox.cometd._ack = new function(){
+ var supportAcks = false;
+ var lastAck = -1;
+
+ this._in = function(msg){
+ if (msg.channel == "/meta/handshake") {
+ supportAcks = msg.ext && msg.ext.ack;
+ } else if (supportAcks && msg.channel == "/meta/connect" && msg.ext && msg.ext.ack && msg.successful) {
+ var ackId = parseInt(msg.ext.ack);
+ lastAck = ackId;
+ }
+ return msg;
+ }
+
+ this._out = function(msg){
+
+ if (msg.channel == "/meta/handshake") {
+ if (!msg.ext)
+ msg.ext = {};
+ msg.ext.ack = dojox.cometd.ackEnabled;
+ lastAck = -1;
+ }
+ if (supportAcks && msg.channel == "/meta/connect") {
+ if (!msg.ext)
+ msg.ext = {};
+ msg.ext.ack = lastAck;
+ }
+ return msg;
+ }
+};
+
+dojox.cometd._extendInList.push(dojo.hitch(dojox.cometd._ack, "_in"));
+dojox.cometd._extendOutList.push(dojo.hitch(dojox.cometd._ack, "_out"));
+dojox.cometd.ackEnabled = true;
+
+});