Google wave pune_gtug

Post on 06-May-2015

620 views 0 download

Tags:

transcript

Programming on Google Wave

By Rohit GhatolFrom

Pune Google Technology User Grouphttp://pune-gtug.blogspot.com

http://blog.punegtug.org

What is Pune-GTUG?

GTUG stands for Google Technology User Group

http://blog.punegtug.org

Google Wave

http://blog.punegtug.org

Topics

• What is Wave?• Anatomy of a Wave• What can be done on GoogleWave?• Extending Google Wave• Writing Gadgets• Writing Robots

http://blog.punegtug.org

http://blog.punegtug.org

What is Wave?A wave is equal parts conversation and document.

People can communicate and work together with richly formatted text, photos, videos, maps, and more.

A wave is shared. Any participant can reply anywhere in the message, edit the content and add participants at any point in the process. Then playback lets anyone rewind the wave to see who said what and when.

A wave is live. 

With live transmission as you type, participants on a wave can have faster conversations, see edits and interact with extensions in real-time.

http://blog.punegtug.org

What is Wave?

Lets see Wave in action!

Topics

• What is Wave?• Anatomy of a Wave• What can be done on GoogleWave?• Extending Google Wave• Writing Gadgets• Writing Robots

http://blog.punegtug.org

http://blog.punegtug.org

Anatomy of a Wave

WaveA wave is a threaded conversation, consisting of one or more participants (which may include both human participants and robots). The wave is a dynamic entity which contains state and stores historical information. A wave is a living thing, with participants communicating and modifying the wave in real time. A wave serves as a container for one or more wavelets defined below.

http://blog.punegtug.org

Anatomy of a Wave

WaveletA wavelet is a threaded conversation that is spawned from a wave (including the initial conversation). Wavelets serve as the container for one or more messages, known as blips. The wavelet is the basic unit of access control for data in the wave. All participants on a wavelet have full read/write access to all of the content within the wavelet.

http://blog.punegtug.org

Anatomy of a Wave

BlipA blip is the basic unit of conversation and consists of a single messages which appears on a wavelet. Blips may either be drafts or published (by clicking "Done" within the Wave client). Blips manage their content through their document, defined below. Blips may also contain other blips as children, forming a blip hierarchy. Each wavelet always consists of at least one root blip.

http://blog.punegtug.org

Anatomy of a Wave

DocumentA document is the content attached to a blip. This document consists of XML which can be retrieved, modified or added by the API. Generally, you manage the document through convenience methods rather than through direct manipulation of the XML data structure.

Topics

• What is Wave?• Anatomy of a Wave• What can be done on GoogleWave?• Extending Google Wave• Writing Gadgets• Writing Robots

http://blog.punegtug.org

http://blog.punegtug.org

What can be done on Google Wave?

• Real time Chat

• Editing as a Document

• Real time collaboration

• Robots participating

Topics

• What is Wave?• Anatomy of a Wave• What can be done on GoogleWave?• Extending Google Wave• Writing Gadgets• Writing Robots

http://blog.punegtug.org

http://blog.punegtug.org

Extending Google Wave?

• Gadgets– Runs on the client.

– Multiple instances per wave.

– Not able to modify the wave, and has limited visibility into the wave. Is only able to detect changes in the wave's participants.

– Not only can't modify a robot, has no way to know that the robot exists.

• Robots– Runs in the cloud.

– One instance of a given robot per wave. Remember that a robot is like a participant on a wave, so each participant/robot is a unique instance, but a wave can have many participants/robots.

– Able to modify a wave and perform the same operations as a human participant.

– Can modify a gadget.

Topics

• What is Wave?• Anatomy of a Wave• What can be done on GoogleWave?• Extending Google Wave• Writing Gadgets• Writing Robots

http://blog.punegtug.org

Writing Gadgets

• Polling Gadget– Allows the host to set the title– All the participants can add Options– Everyone can vote on the Options

Writing Gadgets

Polling Gadget

function renderPoll(){…….}

EventsEvent Callback

State Event

ParticipantEvent

Writing Gadgets

Polling Gadget Polling Gadget

Central State

Update State

Polling GadgetPolling Gadget

Notify via callbacks

Interacting with wave participants and state

Writing Robots

• Steps– Get Google App Engine Account– Get Google App Engine Eclipse plugin– Get Web Application Project

Robot Architecture

Writing Robots

• Robot is a Java Web Application deployed on GAE

• Contains– A Servlet

– capabilities.xml

– web.xml

– appengine-web.xml

Robot Servletpublic class IterationServlet extends AbstractRobotServlet {

public void processEvents(RobotMessageBundle context) {TextView textView = context.getWavelet().getRootBlip().getDocument();//Condition to check if Robot was recently addedif(context.wasSelfAdded()){

//Example of adding a TexttextView.append("Robot: I have been just added to this wave");

//Example of adding a FormtextView.appendElement(new FormElement(ElementType.LABEL,

"NAME_LABEL", "What is your name? :"));textView.appendElement(new FormElement(ElementType.INPUT,

"NAME_INPUT"));textView.appendElement(new FormElement(ElementType.BUTTON,

"SUBMIT_BUTTON", "Submit"));

//Example of adding a GadgetGadget gadget = new Gadget("http://xyz.com/Iteration.gadget.xml");gadget.setField("country", "India");

textView.appendElement(gadget);}

}}

capabilities.xml

<?xml version="1.0"?><w:robot xmlns:w="http://wave.google.com/extensions/robots/1.0">

<w:capabilities> <w:capability name="wavelet_participants_changed"/> <w:capability name="document_changed"/> <w:capability name="form_button_clicked" content="true" /> </w:capabilities>

<w:crons> <w:cron path="/_wave/robot/fetchupdate" timerinseconds="3600" /> </w:crons>

<w:profile name="waveiteration" imageurl="/images/icon.png" profileurl="/_wave/profile.xml" /></w:robot>

Robot API Overview

Robots + Gadget

• Further we will talk about how to use Robots and Gadgets in conjunction with each other

• Here is a Product Idea

Account of rohitsghatol@wavesandbox.com

Account of rohitsghatol@wavesandbox.com

Account of rohitsghatol@wavesandbox.com

Account of rohitsghatol@wavesandbox.com

Account of rohitsghatol@wavesandbox.com

Account of rohitsghatol-test@wavesandbox.com

Robot wrote the updates from the Gadget to a Google Spreadsheet

Robots + Gadget

Create Wave

Add Robot

Present a Form

Submit Form

Create New Wave

Add Participants

Add Gadget

Add State toGadget

Interacts with Gadget

Get Gadget State

Store data on

Spreadsheet

User Action

Robot kicks in

Questions?

?

http://blog.punegtug.org