diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /js/dojo-1.7.2/dojox/rpc/Client.js | |
Diffstat (limited to 'js/dojo-1.7.2/dojox/rpc/Client.js')
| -rw-r--r-- | js/dojo-1.7.2/dojox/rpc/Client.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/js/dojo-1.7.2/dojox/rpc/Client.js b/js/dojo-1.7.2/dojox/rpc/Client.js new file mode 100644 index 0000000..2da1981 --- /dev/null +++ b/js/dojo-1.7.2/dojox/rpc/Client.js @@ -0,0 +1,29 @@ +//>>built +define("dojox/rpc/Client", ["dojo", "dojox"], function(dojo, dojox) { + + dojo.getObject("rpc.Client", true, dojox); + + // Provide extra headers for robust client and server communication + + dojo._defaultXhr = dojo.xhr; + dojo.xhr = function(method,args){ + var headers = args.headers = args.headers || {}; + // set the client id, this can be used by servers to maintain state information with the + // a specific client. Many servers rely on sessions for this, but sessions are shared + // between tabs/windows, so this is not appropriate for application state, it + // really only useful for storing user authentication + headers["Client-Id"] = dojox.rpc.Client.clientId; + // set the sequence id. HTTP is non-deterministic, message can arrive at the server + // out of order. In complex Ajax applications, it may be more to ensure that messages + // can be properly sequenced deterministically. This applies a sequency id to each + // XHR request so that the server can order them. + headers["Seq-Id"] = dojox._reqSeqId = (dojox._reqSeqId||0)+1; + return dojo._defaultXhr.apply(dojo,arguments); + } + + // initiate the client id to a good random number + dojox.rpc.Client.clientId = (Math.random() + '').substring(2,14) + (new Date().getTime() + '').substring(8,13); + + return dojox.rpc.Client; + +}); |
