Java Reference
In-Depth Information
import com.google.wave.api.*;
public class Wave_ApressServlet extends AbstractRobotServlet{
@Override
public void processEvents(RobotMessageBundle bundle) {
Wavelet wavelet = bundle.getWavelet();
if (bundle.wasSelfAdded()){
Blip b = wavelet.appendBlip();
TextView t = b.getDocument();
t.append("This is the welcome message when I join a
Wave");
}
for (Event e : bundle.getEvents()) {
if (e.getType() == EventType.BLIP_SUBMITTED) {
submit(wavelet, e.getBlip());
}
}
}
private void submit(Wavelet wavelet, Blip blip)
{
TextView t = blip.getDocument();
String str = t.getText();
if (Pattern.matches("apress", str)) {
t.append("\n\nHow's the topic?");
}
}
}
Listing 9-6. capabilities.xml
<?xml version="1.0" encoding="utf-8"?>
<w:robot xmlns:w=" http://wave.google.com/extensions/robots/1.0 ">
<w:capabilities>
<w:capability name="BLIP_SUBMITTED" content="true" />
</w:capabilities>
<w:version>0.6</w:version>
<w:profile name="Wave_Apress" profileurl="/_wave/profile.xml"/>
</w:robot>
Search WWH ::




Custom Search