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.

The method you choose to employ depends on your environment; there is nosingle pattern that all Sametime Bots must conform to. bots can run on either theclient or the server. You may find it easier and more convenient to write anddeploy your bots as servlets, for example, if you have access to a suitableapplication server.Regardless of which approach you take to create your bot, there are a fewfundamental things that all bots must do:1. Create a Sametime session and load the necessary components.2. Log in to the Sametime community.3. Register the type of messages the bot should receive.4. Listen for any incoming instant messages.5. Respond accordingly; this is where the bot-specific application logic shouldbe inserted, to analyze the user’s request and select an appropriate responseor action.Using the Java Client Toolkit, we will now look at these five steps in greaterdetail.3.2.1 Creating a Sametime sessionThe first thing any bot application must do is create a Sametime session. EverySametime session must have a unique name that can be used as a key toaccess it from the static session table that the server uses to hold all sessionobjects. We can use the Java keyword this to help derive a unique name. If thesession name is already in use, an exception will be thrown that must be caught.Example 3-1 contains an example of creating an STSession object.Example 3-1 Creating an STSession objecttry{m_session = new STSession(“MySametimeBot” + this);}catch (DuplicateObjectException doe){doe.printStackTrace();return;}If the Sametime session is created successfully, the next step is to load thesession into the Sametime component functions needed by the bot. Sametimefunctionality is split among several components, each responsible for providing a52 <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!