Upload
jerobins
View
658
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Introduction to Google Wave Gadget and and Robot APIs. Presentation given May 26, 2010 at the National Extension Technology Conference in Auburn, Alabama. War Eagle!
Citation preview
Getting Started WithGoogle Wave Development
James E. Robinson, III NC State [email protected] NETC 2010
Google Wave v/s Google wave
Wave - the Wave protocol
wave - The Google wave web app
Wave Anatomy
Wavelet Anatomy
Wavelet Anatomy (cont.)
BlipsParticipantsTagsData Documentsmetadata
creatorcreation_timelast_modified_timerobottitle
Blip Anatomy
Blip Anatomy (cont.)
DocumentAnnotationsChildrenParent (if not already)metadata
creatorcontributorslast_modifiedversion
Gadgets: n, dynamic web content that can be placed on any page on the web. Gadgets can be games, mini applications, news feeds, maps or any content.
See also: JavaScript on steroids.
<?xml version="1.0" encoding="UTF-8" ?><Module> <ModulePrefs title="Hello, World"> <Require feature="wave" /> </ModulePrefs> <Content type="html"> Hello, World! </Content></Module>
Wave Gadget API
setStateCallbackgetStatesetPrivateStateCallbackgetPrivateStatesubmitDeltasetParticipantCallback
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Counter/State Example" height="120"> <Require feature="wave" /> </ModulePrefs>
Gadget API Example
<Content type="html"><![CDATA[
<div id="content_div" style="height: 50px;"></div>
<input type=button value="Click Me!" id="butCount" onClick="buttonClicked()">
<input type=button value="Reset" id="butReset" onClick="resetCounter()">
<script type="text/javascript">
var div = $('content_div');
function init() { if (wave && wave.isInWaveContainer()) { wave.setStateCallback(stateUpdated); } }
gadgets.util.registerOnLoadHandler(init);
function buttonClicked() { var val = wave.getState().get('count', '0'); wave.getState().submitDelta( {'count': val + 1}); }
function stateUpdated() { if (!wave.getState().get('count')) { div.innerHTML = "The count is 0." } else { div.innerHTML = "The count is " + wave.getState().get('count'); } }
// Reset value of "count" to 0 function resetCounter(){ wave.getState().submitDelta({'count': '0'}); }
</script> ]]> </Content></Module>
Gadget Hosting?
What To Do?
if __name__ == '__main__':
myRobot = robot.Robot('robot name', image_url='http://path.to/icon.png')
myRobot.register_handler( events.WaveletSelfAdded, OnSelfAdded)
myRobot.Run()
Add us a Gadget...
def OnSelfAdded(event, wavelet): blip = event.blip gadget = element.Gadget(GADGET_URL) blip.append(gadget)
Wave Happenings
wavelet_blip_createdwavelet_blip_removed wavelet_participants_changewavelet_self_addedwavelet_self_removed wavelet_title_changedwavelet_timestamp_changedwavelet_version_changed
Blip Happenings
blip_contributors_changed blip_deleted blip_submitted - only fires onceblip_timestamp_changedblip_version_changeddocument_changed - various intervalsform_button_clicked
code.google.com/appengine/downloads.html
Register your new application...
Complex mapping structure
AppName: jerobins-test
Application URL: jerobins-test.appspot.com
Wave Address: [email protected]
Now What?
def OnBlipSubmitted(event, wavelet): blip = event.blip gadget = blip.first(element.Gadget, \ url=GADGET_URL) if gadget: count = gadget.get('count', '0') gadget.update_element({'count', '0'}) blip.append("\nCount before blip" + \ " changed: " + count)
Danger, Will Robinson!
Your robot or gadget may not be the only gadget or robot on the wave.
Annotations
Robot Annotations
def OnWaveletSelfAdded(event, wavelet): blip = event.blip blip.Annotation("my-robot/tag")
def OnButtonClicked(event, wavelet): blip = event.blip annots = blip.annotations if annots.include("my-robot/tag"): """ do MY robot stuff """
Active Robot API
Performing scheduled tasks (e.g. cron jobs) at specified intervalsCreating new waves within Google Wave in response to actions within Google Wave itselfResponding to outside events or services by updating waves or creating new ones
Keep on Wavin' ...