Life cycle and events in Google Wave Robots

In my previous two posts I discussed some basics of getting started with development of Google Wave robots using .Net and then talked about publishing of capabilities.

Let's now see what all events get fired by google wave client and how do you handle them in your robot. First let's see what all events (or capabilities) are available. Here is some information from Google wave api site itself.

Robot Events

The following events which a robot may subscribe to are particularly important:

  • wavelet_blip_created fires when a new wave blip has been created.
  • wavelet_participants_changed fires whenever a participant (including another robot) is added or removed from the wave.
  • wavelet_title_changed fires whenever the wavelet title changes.
  • blip_contributors_changed fires whenever the editors of a blip change.
  • blip_deleted fires whenever a blip is deleted from the wavelet.
  • blip_submitted fires whenever a blip is submitted. Note that this event only fires once the user clicks Done or moves to another blip.
  • document_changed fires whenever content is added to a blip, at various intervals.

I will discuss these events in little bit more details and try to tell you when they get fired

self-added

This event is fired as soon as you add the robot as one of the participant in your wave. It is not manadatory that a robot has to be added when a wave is started. As I mentioned few times, a robot is like a real participant in wave that can be added or removed at any given time. So this event is fired when robot gets added to wave. To handle this event, you will need to override OnWaveletSelfAdded method in your ASHX handler.

wavelet_participants_changed

As soon as robot gets added to a wave, framework sends this event to robot with list of participants who are already part of the wave. Your robot will be included as one of the participants in that list.

wavelet_blip_create

This event is fired when a new blip is created in the wave. An example of creating a new blip could be when you reply to another message. Moment you hit reply link or button, this event is fired. This will be good place to any state initialization in your robot for all new blips that are created. For example if you want to cache ID of the blip for later tracking or things like that, you can do that in this event handler.

document_changed

This event is fired when there is any change in the document. This includes character by character change notification being sent to the robot or participants. You will notice that as you are typing in your wave, your robot is getting these notifications continuously. Since this event is fired very often, it is going to create a lot of network traffic for your robot as well as web server handling the requests. There are couple of things you may want to keep in mind when subscribing to this event:

  • If you are not going to take any action on the document or content while it is being acted on, do not subscribe to this event. This will affect performance of your client application as well web application.
  • Keep the actions as atomic as possible for this event. Especially if your robot is adding new blips or modiying content of the existing blip(s), then long operations in this event handler may give some unwanted UI behavior to your participants.

blip_submitted

This event is fired when a blip is submitted. What this means is that when you hit Done button for your blip, it is no longer in draft mode and it gets submitted. This is one of the most used events because at this point the content of the blip is final (till somebody edits it again). If you are taking action based on final content of the blip, this will be the place where you will do it.

blip_deleted

As name suggests, this is fired when a blip is deleted from wave. If you are keeping some state for a blip in your robot, this will be a good place to perform any clean up or any final actions that need to be taken on that blip.

Other events

There are lot more events that your subscribe to. But the ones that discussed are very basic building blocks of a simple robots. I will discuss other events in my later posts. In next post I will walk through development of a simple debugging robot.

Search

Social

Weather

8.9 °C / 48.1 °F

weather conditions Clouds

Monthly Posts

Blog Tags