You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by "Terlecki, Stephen" <st...@lmco.com> on 2009/09/02 19:02:10 UTC

Having trouble with samedomain rpc callback

I have been having some trouble with a callback for a custom RPC method I created for my container.  The method is pretty simple at this point for debugging purposes and just returns a static value to the caller.  The RPC method is registered and works fine both when the gadget calls to it and when the container responds with the results.  The problem I have is if the gadget is re-rendered to change the view to canvas or just for a refresh.  I tracked the problem into the rpc.js file at the point of the callSameDomain(target, rpc) method.

>From what I have found the first time through the callSameDomain method, the sameDomain array does not have an entry for my target (the calling gadget) and wires up the gadgets.rpc.receiveSameDomain method in this line of code:

sameDomain[target] = targetEl.gadgets.rpc.receiveSameDomain;

The code then falls through to check if the sameDomain[target] is now a function and then calls the wired up function completing the RPC callback.

The problem comes when I re-render (change to canvas view or refresh the gadget) the gadget after a successful RPC callback and make another RPC call in that gadget.  The same method is called - callSameDomain(target, rpc).  This time around the sameDomain[target] still contains the function reference from the initial call and falls through to the call of that function.   That is where I receive an error.  From what I can tell, the re-rendering of the gadget's iframe dereferences the function and now the rpc calls to that gadget are broken until I refresh the entire page.

I don't know if I am missing something silly here, but I am a bit stuck.

Any help would be much appreciated.

Steve T.

Re: Having trouble with samedomain rpc callback

Posted by Kevin Brown <et...@google.com>.
Yeah, that does sound like a limitation of the same domain mechanism. Are
you actually intentionally rendering gadgets on the same domain as the
container though? If so, you may as well just use caja and swap out the
gadgets.rpc implementation entirely. I was planning on writing a cajoled
version of gadgets.rpc but haven't gotten around to it. It shouldn't be more
than 20 lines of code or so.

On Wed, Sep 2, 2009 at 10:02 AM, Terlecki, Stephen <
stephen.terlecki@lmco.com> wrote:

> I have been having some trouble with a callback for a custom RPC method I
> created for my container.  The method is pretty simple at this point for
> debugging purposes and just returns a static value to the caller.  The RPC
> method is registered and works fine both when the gadget calls to it and
> when the container responds with the results.  The problem I have is if the
> gadget is re-rendered to change the view to canvas or just for a refresh.  I
> tracked the problem into the rpc.js file at the point of the
> callSameDomain(target, rpc) method.
>
> From what I have found the first time through the callSameDomain method,
> the sameDomain array does not have an entry for my target (the calling
> gadget) and wires up the gadgets.rpc.receiveSameDomain method in this line
> of code:
>
> sameDomain[target] = targetEl.gadgets.rpc.receiveSameDomain;
>
> The code then falls through to check if the sameDomain[target] is now a
> function and then calls the wired up function completing the RPC callback.
>
> The problem comes when I re-render (change to canvas view or refresh the
> gadget) the gadget after a successful RPC callback and make another RPC call
> in that gadget.  The same method is called - callSameDomain(target, rpc).
>  This time around the sameDomain[target] still contains the function
> reference from the initial call and falls through to the call of that
> function.   That is where I receive an error.  From what I can tell, the
> re-rendering of the gadget's iframe dereferences the function and now the
> rpc calls to that gadget are broken until I refresh the entire page.
>
> I don't know if I am missing something silly here, but I am a bit stuck.
>
> Any help would be much appreciated.
>
> Steve T.
>