Permalink
Browse files

Switched from timestamp call signatures to 10 char random strings.

  • Loading branch information...
1 parent 8f2eba0 commit 87f4f85e885f9ecb4c6bfff7151fa614da315e57 Sridatta Thatipamala committed Apr 18, 2011
Showing with 14 additions and 4 deletions.
  1. +2 −2 lib/nowServerLib.js
  2. +12 −2 lib/nowUtil.js
View
@@ -109,15 +109,15 @@ var nowCore = {
constructRemoteFunction: function(client, fqn) {
nowUtil.debug("constructRemoteFunction", fqn);
var remoteFn = function() {
- var callId = fqn+ "_"+ new Date().getTime();
+ var callId = fqn+ "_"+ nowUtil.generateRandomString(10);
nowUtil.debug("executeRemoteFunction", fqn + ", " + callId);
var theArgs = Array.prototype.slice.call(arguments);
for(var i in theArgs){
if(typeof theArgs[i] === 'function'){
- var closureId = "closure" + "_" + theArgs[i].name + "_" + new Date().getTime();
+ var closureId = "closure" + "_" + theArgs[i].name + "_" + nowUtil.generateRandomString(10);
nowCore.closures[closureId] = theArgs[i];
theArgs[i] = {type: 'function', fqn: closureId};
}
View
@@ -337,7 +337,7 @@
},
debug: function(func, msg){
- // console.log(func + ": " + msg);
+ //console.log(func + ": " + msg);
},
error: function(err){
@@ -516,14 +516,24 @@
}
}
+ },
+
+ generateRandomString: function(length){
+ var charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ var randomString = '';
+ for (var i = 0; i < length; i++) {
+ var randomPoz = Math.floor(Math.random() * charSet.length);
+ randomString += charSet.substring(randomPoz,randomPoz+1);
+ }
+ return randomString;
}
};
if('window' in this) {
-
window.nowUtil = nowUtil;
if(!('JSON' in window)){
+ console.log("Using this PoS non-native JSON shim");
JSON={};
(function(){"use strict";function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+

0 comments on commit 87f4f85

Please sign in to comment.