You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by zh...@apache.org on 2008/05/16 21:16:26 UTC
svn commit: r657173 - /incubator/shindig/trunk/features/rpc/rpc.js
Author: zhen
Date: Fri May 16 12:16:26 2008
New Revision: 657173
URL: http://svn.apache.org/viewvc?rev=657173&view=rev
Log:
Always use IFPC to send cross-domain messages when legacy protocol is enabled.
Modified:
incubator/shindig/trunk/features/rpc/rpc.js
Modified: incubator/shindig/trunk/features/rpc/rpc.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/rpc/rpc.js?rev=657173&r1=657172&r2=657173&view=diff
==============================================================================
--- incubator/shindig/trunk/features/rpc/rpc.js (original)
+++ incubator/shindig/trunk/features/rpc/rpc.js Fri May 16 12:16:26 2008
@@ -287,6 +287,10 @@
t: authToken[targetId]
});
+ if (useLegacyProtocol[targetId]) {
+ relayChannel = 'ifpc';
+ }
+
switch (relayChannel) {
case 'dpm': // use document.postMessage
var targetDoc = targetId === '..' ? parent.document :
@@ -298,27 +302,7 @@
targetWin.postMessage(rpcData);
break;
default: // use 'ifpc' as a fallback mechanism
- // Try the frameElement channel if available
- try {
- if (from === '..') {
- // Container-to-gadget
- var iframe = document.getElementById(targetId);
- if (typeof iframe.__g2c_rpc.__c2g_rpc === 'function') {
- iframe.__g2c_rpc.__c2g_rpc(rpcData);
- return;
- }
- } else {
- // Gadget-to-container
- if (typeof window.frameElement.__g2c_rpc === 'function') {
- window.frameElement.__g2c_rpc(rpcData);
- return;
- }
- }
- } catch (e) {
- }
-
var relay = gadgets.rpc.getRelayUrl(targetId);
-
// TODO split message if too long
var src;
if (useLegacyProtocol[targetId]) {
@@ -327,6 +311,24 @@
encodeLegacyData([from, serviceName, '', '', from].concat(
Array.prototype.slice.call(arguments, 3)))])].join('');
} else {
+ // Try the frameElement channel if available
+ try {
+ if (from === '..') {
+ // Container-to-gadget
+ var iframe = document.getElementById(targetId);
+ if (typeof iframe.__g2c_rpc.__c2g_rpc === 'function') {
+ iframe.__g2c_rpc.__c2g_rpc(rpcData);
+ return;
+ }
+ } else {
+ // Gadget-to-container
+ if (typeof window.frameElement.__g2c_rpc === 'function') {
+ window.frameElement.__g2c_rpc(rpcData);
+ return;
+ }
+ }
+ } catch (e) {
+ }
// # targetId & sourceId@callId & packetNum & packetId & packetData
src = [relay, '#', targetId, '&', from, '@', callId,
'&1&0&', encodeURIComponent(rpcData)].join('');