0

Could I have an example of communication between two OpenSocial gadgets using the gadgets.rpc API?

I've searched for one, but the closest I can find is a deprecated example of gadget-to-container communication.

1
  • The rarity of examples may have something to do with the fact that the initial reference OpenSocial container has a bug that prevents gadget-to-gadget RPC from working - issues.apache.org/jira/browse/SHINDIG-1473
    – pidge
    Nov 19, 2010 at 23:33

1 Answer 1

0

you can use pubsub for gadget-to-gadget communication.

on a gadget, you subscribe for an event as follows:

gadgets.pubsub.subscribe("my_event_type",whenEventHappens);
function whenEventHappens(sender, message){
      alert(message.content);
}

on another gadget, you publish events as follows:

var message = {};
message["content"] = "hey,wassup?";
gadgets.pubsub.publish("my_event_type", message);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.