Added message objects, and converted to and from JSON on both JS and
Java ends.