multiple gadgets sharing state

1 view
Skip to first unread message

rgibson

unread,
Nov 10, 2009, 1:00:59 PM11/10/09
to Google Wave API, rgi...@astro.washington.edu
I would like to share state between multiple gadgets. When I read the
wave gadgets tutorial, it sounded as if the state was stored at the
Wave level. (E.g., call wave.getState() to get the state, gadgets
"share state", etc.) So there would be one "count" per Wave, not one
"count" per gadget.

Of course, this introduces its own problems (e.g., every gadget
developer has to know about the namespace of every other gadget.) And
a quick check shows that if you run two examples of the "count"
example gadget, they each have their own "count" variable that updates
independently.

So is there a way for two gadgets in a Wave to share their state? Or,
what's the best way to do this?

I am new at this and trying to poke my way through the documents, but
I've gotten to the point where it's better to ask.

Thanks,
Rob

Austin Chau (Google employee)

unread,
Nov 10, 2009, 1:37:26 PM11/10/09
to google-...@googlegroups.com
No gadget states are specific to each gadget and not shared among other gadgets within the same wave.

There are several ways to maintain "state" among different gadgets of the same wave, you can maintained your own persistent storage on remote server and use some crossdomain mechanism (jsonp, script injection, etc) to share data.  You can also use wave robot to maintain data for you and store them on the wave data document.

Austin

Vikram Dhillon

unread,
Nov 11, 2009, 12:27:58 AM11/11/09
to google-...@googlegroups.com
Hi,
This could be possible, use a static variable
to keep the track of the state and then since there's only one copy of
that variable, it can accessed at any point in the program/robot :)

--
Regards,
Vikram

rgibson

unread,
Nov 11, 2009, 3:48:46 PM11/11/09
to Google Wave API
Thanks for comments, all. Now suppose I want the gadget to receive a
"state change" notification every time the state has changed. (I
don't want to have to continually poll an external site to see if
something has changed; I want a callback notification.)

Is it true that:
1) There is no good way to get a "state-change" callback if I use the
method where I manually store state in an external site?

2) If I use the robot to manage the state, I _will_ get a callback
when a robot changes the state of any gadget?

Thanks,
Rob



On Nov 10, 9:27 pm, Vikram Dhillon <dhillon...@gmail.com> wrote:
> Hi,
>                        This could be possible, use a static variable
> to keep the track of the state and then since there's only one copy of
> that variable, it can accessed at any point in the program/robot :)
>
> --
> Regards,
> Vikram
>
> On Tue, Nov 10, 2009 at 1:37 PM, Austin Chau (Google employee)
>
> <api.aus...@google.com> wrote:
> > No gadget states are specific to each gadget and not shared among other
> > gadgets within the same wave.
>
> > There are several ways to maintain "state" among different gadgets of the
> > same wave, you can maintained your own persistent storage on remote server
> > and use some crossdomain mechanism (jsonp, script injection, etc) to share
> > data.  You can also use wave robot to maintain data for you and store them
> > on the wave data document.
>
> > Austin
>
> > On Tue, Nov 10, 2009 at 10:00 AM, rgibson <rgib...@astro.washington.edu>

Austin Chau (Google employee)

unread,
Nov 11, 2009, 3:54:21 PM11/11/09
to google-...@googlegroups.com
1) You are correct. The callback mechanism provided by gadget library is only connected to the wave server.

2) Yes.  When robot changed gadget states  your gadget will receive the callback.

Austin

rgibson

unread,
Nov 11, 2009, 4:04:54 PM11/11/09
to Google Wave API
Makes sense. Is there any way to get the state change callbacks
_without_ using the robot to manage the shared states?

(And without writing my own communication protocol that is, at the
bottom layers, just polling an offsite server?)

Thanks,
Rob


On Nov 11, 12:54 pm, "Austin Chau (Google employee)"
<api.aus...@google.com> wrote:
> 1) You are correct. The callback mechanism provided by gadget library is
> only connected to the wave server.
>
> 2) Yes.  When robot changed gadget states  your gadget will receive the
> callback.
>
> Austin
>

Niels H. Christensen

unread,
Nov 11, 2009, 5:05:45 PM11/11/09
to Google Wave API
> Makes sense.  Is there any way to get the state change callbacks
> _without_ using the robot to manage the shared states?

I don't think so. To get a callback you either need
- someone (robot or ordinary user) to join or leave the Wave,
- or someone (robot or ordinary user) to change a gadget state,
- or the user must change the mode of the gadget (start/stop
playback or editing).
At least, that's how I read http://code.google.com/apis/wave/extensions/gadgets/reference.html

So it's a bot...or yourself with a pen and pencil. :-)

cmdskp

unread,
Nov 11, 2009, 8:28:29 PM11/11/09
to Google Wave API
If you end up using a Java robot and a static object variable -
remember to ensure you synchronize on it or use a synchronized
object. Otherwise, simultaneous Servlet requests can end up changing
the shared static object's value before each request is done with it.

On Nov 11, 10:05 pm, "Niels H. Christensen"

just marvin

unread,
Nov 12, 2009, 10:48:43 AM11/12/09
to Google Wave API
It occurs to me that since you'll need a bot and a gadget, you could
just have the bot add the gadget(s) to the wave. Then you just need
to add one thing to the wave and you'll know you have the correct
environment for the gadgets.

Jacco

unread,
Nov 16, 2009, 11:02:36 AM11/16/09
to Google Wave API
I think currently communicating from robot to gadget is not possible?

The gadget.setField does not change the state of the gadget in my
tests.

Regards, Jacco

pamela (Google Employee)

unread,
Nov 17, 2009, 4:56:10 AM11/17/09
to google-...@googlegroups.com
It does work, and many robots do so, but there are some bugs filed about cases where it does not work. For example:


--

You received this message because you are subscribed to the Google Groups "Google Wave API" group.
To post to this group, send email to google-...@googlegroups.com.
To unsubscribe from this group, send email to google-wave-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=.



Reply all
Reply to author
Forward
0 new messages