Skip to content
Browse files

new features added

  • Loading branch information...
1 parent fa0f244 commit 401a587ab313ada87b0f222f9f9660c1eff88190 @alejandrolechuga committed Apr 21, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 redCross.1.0.js
View
18 redCross.1.0.js
@@ -19,7 +19,8 @@
isParentWindow = global.parent === global,
clientStack = [],
serverStack = [],
- debugEnabled = false;
+ debugEnabled = false,
+ keyCounter = 0;
// Enables debugmode
// @param Boolean bool
@@ -76,8 +77,11 @@
// Generates a key ID for every client instance
// @return Integer
- RedCross.generateKey = function () {
- return (new Date().getTime());
+ RedCross.generateKey = function (type) {
+ var key = (new Date().getTime());
+ keyCounter = keyCounter + 1;
+ key = type + keyCounter + "-" + key;
+ return key;
};
// Creates a packet string using JSON.stringify
@@ -114,10 +118,10 @@
});
client.type = "client";
client.parent = global;
- client.key = RedCross.generateKey();
+ client.key = RedCross.generateKey("client");
client.domain = RedCross.getDomainFromURL(url);
-
clientStack.push(client);
+
client.message = function (message) {
RedCross.message(this, message);
};
@@ -136,6 +140,7 @@
RedCross.message = function (client, message) {
var packet = RedCross.pack(client, message);
if (postMessage) {
+ //console.log(packet);
client.window.contentWindow.postMessage(packet, "*");
}
};
@@ -153,7 +158,8 @@
if (postMessage) {
RedCross.listenPostMessageFromServer(args);
}
- serverStack.policy = args.policy;
+ server.policy = args.policy;
+ server.key = RedCross.generateKey("server");
serverStack.push(server);
return server;
};

0 comments on commit 401a587

Please sign in to comment.
Something went wrong with that request. Please try again.