It’s just data

Wave Robot Ruby Client

Wanting to learn more about Google Wave, I ported the Wave Robot Python Client library to Ruby, mainly because I wanted to understand the protocol.  The current protocol is tightly coupled to the Java server implementation.

>>> import waveapi.document
>>> import waveapi.util
>>> waveapi.util.Serialize([waveapi.document.Image('http://example.com/foo.jpg', width=100, height=100)])
{'javaClass': 'java.util.ArrayList', 'list': [{'type': 'IMAGE', 'properties': {'javaClass': 'java.util.HashMap', 'map': {'url': 'http://example.com/foo.jpg', 'width': 100, 'height': 100}}, 'java_class': 'com.google.wave.api.Image'}]}

In addition to being littered with javaClass names and requiring 5 levels of nesting to represent an array of a single Image, this serialization is not strictly JSON as it uses single quotes, something that the builtin library for Ruby chokes on:

$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'json'
=> true
irb(main):003:0> JSON.parse('["foo"]')
=> ["foo"]
irb(main):004:0> JSON.parse("['foo']")
JSON::ParserError: 349: unexpected token at ''foo']'

But, in any case, the Ruby implementation can now match the function:

$ irb
irb(main):001:0> require 'document'
=> true
irb(main):002:0> Util.Serialize([Image.new('http://example.com/foo.jpg', :width=>100, :height=>100)])
=> {"list"=>[{"java_class"=>"com.google.wave.api.Image", "type"=>"IMAGE", "properties"=>{"javaClass"=>"java.util.HashMap", "map"=>{"url"=>"http://example.com/foo.jpg", "height"=>100, "width"=>100}} }], "javaClass"=>"java.util.ArrayList"}

Other than the use of double quotes and the ordering of Hash keys, these results match.

Additional notes, in no particular order:

Overall, I feel that this Google Wave could benefit from earlier and wider reviews.  In particular, the whole approach to JSON generation should be rethought.  I look forward to testing interop with a live server, in particular one that I can self host.


Google Wave API Google Group

Posted by Sam Ruby at

I guess that explains why they recommended using their libraries and warned that the underlying protocol would change. They wrote it so Java could easily talk to Java, and put off making it language-neutral till later.

Posted by Charlie O'Keefe at

[from dajobe] Wave Robot Ruby Client - Sam Ruby

[link]...

Excerpt from Delicious/network/gavin at

I guess that explains why they recommended using their libraries and warned that the underlying protocol would change. They wrote it so Java could easily talk to Java, and put off making it language-neutral till later.

I certainly hope so anyways.  It’d suck if it stays that way.

Posted by Bob Aman at

Hi Sam, Charlie and all.... your thoughts are right on... The Java API was implemented first... We are working on de-Java-fying the wire protocol and making the python robot client library more “pythonic”. Keep the feedback/comments coming and feel free to improve upon our work in your own client libraries :)

Posted by Seth Covitz (Google Employee) at

Seth: is there a process by which contributions can be made to the Python client libraries?  I’d gladly prepare a number of patches...

Posted by Sam Ruby at

Four short links: 4 June 2009

Wave Robot Ruby Client — Sam Ruby ported the Wave Robot Python Client library to Ruby. He found that the wire protocol is full of Java classnames, and says, Overall, I feel that this Google Wave could benefit from earlier and wider reviews. In the...

Excerpt from O'Reilly Radar - Insight, analysis, and research about emerging technologies. at

Hey Sam. We’re looking to publish the wire protocol soon which I am sure will open lots of opportunities for client libraries. We haven’t worked out how exactly to take submissions from the wider community just yet, but when we do we’ll let you know.

Posted by Seth Covitz (Google Employee) at

Wave Protocol Thoughts

An upfront disclaimer, I work for Google. I am not involved in Wave in any way and all of the things I discuss below are based on external documentation. Before getting into the specifics of the issues I found, I want to point out that I’m very...

Excerpt from Joe Gregorio | BitWorking at

Sam Ruby: Wave Robot Ruby Client

Wanting to learn more about Google Wave, I ported the Wave Robot Python Client library to Ruby, mainly because I wanted to understand the protocol. The current protocol is tightly coupled to the Java server implementation. (Link: Sam Ruby: Wave...

Excerpt from Brent Sordyl's blog at

Add your comment