First Experience with Google Wave Robot

Today, JP and I built our first Google Wave Robot. It was quite an excercise in frustration. We followed this tutorial and found that it is well put together and straightforward.

After creating an App Engine account, we built the tutorial as-is in order to verify the procedure was correct. Simple enough until we tested the Robot. The code looks like it was supposed to emit “I’m Alive!” whenever it was added to the Wave and “Hi, Everybody!” when any other participant was added. But we ended up seeing “I’m Alive!I’m Alive!” in one Wavelet and “Hi, Everybody!Hi, Everybody!” in another Wavelet. Examining the code and examining the wavelet data in the debug view we could not figure out any way that using TextView.append would cause this unless something was horribly broken. For example, the following code:

would output the text twice in the same blip.

So we started printing out all sorts of information in order to figure out what was going on. At this time, we discovered that putting a newline (\n) into the blip did not actually cause a line break. Well, of course. It must be the HTML <br> element. Nope. Nothing we tried worked. But this was just a small annoyance, making the returned debugging text difficult to read.

After hours of testing, we stumbled upon a post pointing out  the bug for the doubled text. A nice fresh bug, 2 days old. Causes repeated text when using the TextView.append() method. At least there is a workaround. If you do a delete() on the TextView prior to the append(), the text does not get repeated.

Then we discover a post that shows that the newline used to work, but now you need to use spaces around the newline for a linebreak to occur. eg. ” \n “. Note the spaces below:

Now that we have the sample working the way it should, we can modify it to accomplish something useful. Hopefully the process will not be as frustrating.