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 20:01:51 UTC
[jira] Commented: (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:comment-tabpanel&focusedCommentId=12914564#action_12914564 ]
Damian Biollo commented on SHINDIG-1432:
----------------------------------------
Here's the change I made on my copy of the code to fix the problem. If you like it, please apply to trunk.
File: shindig-trunk/features/src/main/javascript/features/shindig.container/osapi.js
Line: 63
*Before*
current(requests[i].params, function(i) {
return function(response) {
// Put back in json-rpc format
responses[i] = { id : requests[i].id, data : response};
callCount++;
if (callCount == requests.length) {
callback(responses);
}
};
}(i));
*After*
current.apply(this, [requests[i].params, function(i) {
return function(response) {
// Put back in json-rpc format
responses[i] = { id : requests[i].id, data : response};
callCount++;
if (callCount == requests.length) {
callback(responses);
}
};
}(i)]);
With this change I can now find out the source gadget and do something appropriate. ex:
osapi.appdata = {
update: function (request, callback) {
var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
var gadget = shindig.container.getGadget(id);
// set appdata for this gadget ...
}
}
> 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.