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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 3-12 Document created by bot for possible inclusion in FAQs3.3.3 Translator BotThis third bot is also built upon the SametimeBot abstract class introduced in“SametimeBot” on page 61. It uses the BabelFish <strong>Web</strong> service hosted byXMethods (http://www.xmethods.net) to provide language translation. The enduser enters a two digit code representing their own language, and a two digitcode representing the language they wish to receive the translation in. The userthen types in the word or phrase they wish to translate. The bot passes thephrase on to the <strong>Web</strong> service, along with the language preferences chosen bythe user. The bot then sends the translation provided by the <strong>Web</strong> service back tothe user.We have added functionality to this bot so that the user can change theirlanguage preferences at any time. The bot will remember the user’s currentpreferences for the duration of their chat session. The user’s preferences couldof course be stored persistently, but we have left this as an exercise for thereader.The Translator Bot is implemented by the TranslatorBot class, which extends theSametimeBot abstract class. As the majority of the code is very similar to that inthe previous section, we only detail the changes here.SametimeBotTo allow for the user’s language preferences to be changed during their chatsession, we add a Hashtable object to the SametimeBot class:protected Hashtable imState = new Hashtable();We change the doTextReceived() method to include a reference to the Hashtableas one of its parameters. This gives the TranslatorBot subclass access to theHashtable and its contents:abstract protected String doTextReceived(ImEvent event, String strReceivedText,Hashtable imState);74 <strong>Lotus</strong> <strong>Instant</strong> <strong>Messaging</strong>/<strong>Web</strong> <strong>Conferencing</strong> (Sametime): Building Sametime-Enabled Applications

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

Saved successfully!

Ooh no, something went wrong!