10.07.2015 Views

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

the textReceived() method is called. The bot retrieves the order number sent to itusing the getText() method of the ImEvent object:public void textReceived(ImEvent e){String messageText = e.getText();int sprInt = new Integer(messageText).intValue();Example 12-1 shows how the bot uses a Java switch / case statement to selectthe details for a particular order. It uses the sendData() method of the Im objectto send four lots of binary data back to the applet. The bot then uses thesendText() method to echo back to the applet the order number it sent.Example 12-1 Portion of bot’s textReceived() methodswitch (sprInt){case 1:strDescription = "Arizona sunset watercolour";e.getIm().sendData(true, 100001, 5, strDescription.getBytes());strReportedBy = "Dave";e.getIm().sendData(true, 100001, 6, strReportedBy.getBytes());strStatus = "Awaiting delivery to customer";e.getIm().sendData(true, 100001, 7, strStatus.getBytes());strImageURL = "AZSunc.jpg";e.getIm().sendData(true, 100001, 8, strImageURL.getBytes());e.getIm().sendText(true, "SPR " + messageText);break;case 2:strDescription = "The Diver's watch";e.getIm().sendData(true, 100001, 5, strDescription.getBytes());strReportedBy = "Max";e.getIm().sendData(true, 100001, 6, strReportedBy.getBytes());strStatus = "Out of oxygen";e.getIm().sendData(true, 100001, 7, strStatus.getBytes());strImageURL = "watchlg.jpg";e.getIm().sendData(true, 100001, 8, strImageURL.getBytes());e.getIm().sendText(true, "SPR " + messageText);break;case 3:strDescription = "A wearable PC";e.getIm().sendData(true, 100001, 5, strDescription.getBytes());strReportedBy = "Charlie";e.getIm().sendData(true, 100001, 6, strReportedBy.getBytes());strStatus = "Waiting for taxi";e.getIm().sendData(true, 100001, 7, strStatus.getBytes());strImageURL = "wearpclg.gif";Chapter 12. Ideas for customization and integration 335

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!