You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "Damian Biollo (JIRA)" <ji...@apache.org> on 2010/09/24 19:45:34 UTC

[jira] Updated: (SHINDIG-1432) shindig.container's _handleGadgetRpcMethod doesn't allow you to implement osapi functions as advertised

     [ https://issues.apache.org/jira/browse/SHINDIG-1432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Damian Biollo updated SHINDIG-1432:
-----------------------------------

    Description: 
Trying to use gadgetsrpctransport for a container custom osapi implementation and found that it doesn't work.

I've disabled the JSON-RPC osapi service and am hooking up custom osapi code in my container. My container.js config file has these settings:
  "osapi.services" : {
    "gadgets.rpc" : ["appdata.update"] 
  },
  "osapi" : {
    "endPoints" : [] 
  },


With JSON-RPC disabled, gadgetsrpctransport.js code in osapi feature is active. For any osapi call, like osapi.appdata.update, It sends sends an RPC call to the container, which is handled by osapi._handleGadgetRpcMethod(), which is found in osapi.js in shindig.container feature.

In my custom container code I implemented a simple osapi handler for appdata.update:

osapi.appdata = {
            update: function (request, callback) {
                console.log("Yeah!");
            }
        }

The code gets hit when I call appdata.update from my gadget. Unfortunately, the container can't do anything meaningful because the originating gadget is lost. I have no idea which of the many gadgets on my page sent the appdata.update message! Note that "this" = window within the update function.


_handleGadgetRpcMethod really needs to preserve the gadget info. I'd suggest something like what is done for setprefs and other RPC APIs. When _handleGadgetRpcMethod is called from the process() function in rpc.js, the "this" point is set to the rpc object, which allows access to the gadget like so:

  var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
  var gadget = shindig.container.getGadget(id);



So, without some improvements to _handleGadgetRpcMethod it is not possible to implement a useful osapi in the container.

  was:
Trying to use gadgetsrpctransport for a container custom osapi implementation and found that it doesn't work.

I've disabled the JSON-RPC osapi service and am hooking up custom osapi code in my container. My container.js config file has these settings:
{code}
  "osapi.services" : {
    "gadgets.rpc" : ["appdata.update"] 
  },
  "osapi" : {
    "endPoints" : [] 
  },
{code}

With JSON-RPC disabled, gadgetsrpctransport.js code in osapi feature is active. For any osapi call, like osapi.appdata.update, It sends sends an RPC call to the container, which is handled by osapi._handleGadgetRpcMethod(), which is found in osapi.js in shindig.container feature.

In my custom container code I implemented a simple osapi handler for appdata.update:

{code}
osapi.appdata = {
            update: function (request, callback) {
                console.log("Yeah!");
            }
        }
{code}

The code gets hit when I call appdata.update from my gadget. Unfortunately, the container can't do anything meaningful because the originating gadget is lost. I have no idea which of the many gadgets on my page sent the appdata.update message! Note that "this" = window within the update function.


_handleGadgetRpcMethod really needs to preserve the gadget info. I'd suggest something like what is done for setprefs and other RPC APIs. When _handleGadgetRpcMethod is called from the process() function in rpc.js, the "this" point is set to the rpc object, which allows access to the gadget like so:
{code}
  var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
  var gadget = shindig.container.getGadget(id);
{code}


So, without some improvements to _handleGadgetRpcMethod it is not possible to implement a useful osapi in the container.


> shindig.container's _handleGadgetRpcMethod doesn't allow you to implement osapi functions as advertised
> -------------------------------------------------------------------------------------------------------
>
>                 Key: SHINDIG-1432
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1432
>             Project: Shindig
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Damian Biollo
>
> Trying to use gadgetsrpctransport for a container custom osapi implementation and found that it doesn't work.
> I've disabled the JSON-RPC osapi service and am hooking up custom osapi code in my container. My container.js config file has these settings:
>   "osapi.services" : {
>     "gadgets.rpc" : ["appdata.update"] 
>   },
>   "osapi" : {
>     "endPoints" : [] 
>   },
> With JSON-RPC disabled, gadgetsrpctransport.js code in osapi feature is active. For any osapi call, like osapi.appdata.update, It sends sends an RPC call to the container, which is handled by osapi._handleGadgetRpcMethod(), which is found in osapi.js in shindig.container feature.
> In my custom container code I implemented a simple osapi handler for appdata.update:
> osapi.appdata = {
>             update: function (request, callback) {
>                 console.log("Yeah!");
>             }
>         }
> The code gets hit when I call appdata.update from my gadget. Unfortunately, the container can't do anything meaningful because the originating gadget is lost. I have no idea which of the many gadgets on my page sent the appdata.update message! Note that "this" = window within the update function.
> _handleGadgetRpcMethod really needs to preserve the gadget info. I'd suggest something like what is done for setprefs and other RPC APIs. When _handleGadgetRpcMethod is called from the process() function in rpc.js, the "this" point is set to the rpc object, which allows access to the gadget like so:
>   var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
>   var gadget = shindig.container.getGadget(id);
> So, without some improvements to _handleGadgetRpcMethod it is not possible to implement a useful osapi in the container.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.