Skip to content

Instantly share code, notes, and snippets.

@findchris
Created December 7, 2011 02:29
Show Gist options
  • Select an option

  • Save findchris/1441158 to your computer and use it in GitHub Desktop.

Select an option

Save findchris/1441158 to your computer and use it in GitHub Desktop.
consumer page easyXDM Rpc
new easyXDM.Rpc(
{
swf: "http://ourstaticcontent/easyxdm.swf",
remote: content_url, // the URL of iframe opened by the consumer
container: container, // the iframe object
onReady: function() {
console.log('activityFrameLoaded: onReady'); // this gets called
}
},
{
remote: {},
local: {
test:function(){...}
}
});
@findchris

Copy link
Copy Markdown
Author

Assuming I have the terms correct, my provider and content page are the same, to be loaded in an iframe by the consumer. Is this possible?

If not, one option I'm considering is to have the consumer create a div, which they'll pass to me, and I'll create the iframe myself. This might work ok, but I'd still prefer to use the above method as I won't have to change my API.

Thanks again for your correspondence.

@findchris

Copy link
Copy Markdown
Author

We posted at the same time. I'll try what you've suggested, thanks.

@findchris

Copy link
Copy Markdown
Author

You stress not to create the iframe, which makes sense, but as it stands right now the consumer/host will create the iframe and set it's src to what they get from my API. Could this work with the host page creating the iframe? If not, what you describe is:
(1) Host/consumer page creates a container (e.g. div)
(2) Host/consumer page let's my code know that it wants the iframe to be created inside of this div.
(3) I create an easyXDM RPC with the container set to the div from (1).
(4) This will create the iframe with the desired content in the provided container div.

Does that sound accurate?

@oyvindkinsey

oyvindkinsey commented Dec 7, 2011 via email

Copy link
Copy Markdown

@findchris

Copy link
Copy Markdown
Author

Ok, thanks. I set up the end point like so (in my content page):

easy_xdm_proxy = new easyXDM.Rpc(
{
  swf: document.location.protocol + "//static.site/js/easyxdm.swf",
  onReady: function() { console.log('provider onReady'); }
},
{
  remote: { start: {} },
  local: { }
});

And... the pages are communicating successfully. Despite this, I am seeing the following common XDM communication error:

Unsafe JavaScript attempt to access frame with URL http://testconsumer.com:3000/# from frame with URL http://provider/page?var=1&xdm_c=default1709&xdm_e=http%3A%2F%2Ftestconsumer.com%3A3000&xdm_p=1. Domains, protocols and ports must match.

Like I said, communication seems to work, so wondering why these errors are showing up. It looks like it occurs twice in the provider when the easyXDM RPC is created, and once in the consumer when the RPC is created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment