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.

import com.lotus.sametime.community.*;import com.lotus.sametime.core.comparch.*;import com.lotus.sametime.core.constants.*;import com.lotus.sametime.im.*;abstract class SametimeBotextends HttpServletimplements LoginListener,ImServiceListener,ImListenerThe class then defines variables for the STSession, CommunityService, and<strong>Instant</strong><strong>Messaging</strong>Service objects, as well as four methods that are overridden ineach bot subclass to return the welcome greeting, server name, user name, andpassword. A Vector object is created to keep track of the bot’s open IM sessions(see Example 3-4 for details).Example 3-4 Variable definitionsabstract protected String getWELCOME_TEXT();abstract protected String getSERVER();abstract protected String getAPP_NAME();abstract protected String getAPP_PASSWORD();private STSession m_session;private CommunityService m_communityService;private <strong>Instant</strong><strong>Messaging</strong>Service m_imService;protected Vector m_imOpened = new Vector();The init() method (Example 3-5) is called when the servlet is loaded into theservlet container. Here we attempt to log in to the Sametime server.Example 3-5 init() methodpublic void init() throws ServletException{System.out.println(this.getServletName() + ": init()");try{login();}catch (Exception e){e.printStackTrace();}62 <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!