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.

8.4.10 Getting a reference to the activitySince we set the default activity for our Place using the server applicationservice, the activityAdded() event will be fired shortly after a user enters thePlace. The following code checks to see if the activity is of the same type as theone we created in our server application. If it is, we store a reference to activityso we can send messages to it later.public void activityAdded(PlaceEvent event) {Activity activity = e.getActivity();}if (event.getActivityType() == ACTIVITY_TYPE) {m_specialActivity = event.getActivity();}8.4.11 Getting references to sectionsAt one point or another, the applet is responsible for moving the users into eitherthe Queue or Lobby sections. Therefore, we need to store a handle for each ofthese sections. The only time the applet can get a reference to these sections iswhen the sectionAdded() event is triggered, which occurs shortly after a userenters the Place. Since these sections are just regular sections that only havemeaning within the application, we need a way to determine which section iswhich. There are a couple of approaches we could have employed. For one, theserver application could have set an attribute on each section. Then when theapplet received the event, it could have checked the attribute to discover whichsection was which. A second approach would have been to send the activity arequest for the Member ID numbers of each of these sections using thesendData() method. The activity could have then replied using the sendData()method and the applet could have responded accordingly. While both theseapproaches have their merits and deficiencies, we choose to implement adifferent approach using an algorithm similar to the one the server applicationuses. Example 8-1 shows the algorithm we used.Example 8-1 sectionAdded() event in PanelDiscussionApplet.javapublic void sectionAdded(PlaceEvent event){Section tempSection;Section newSection = event.getSection();Integer sectionId = newSection.getMemberId();String sectionKey = "Section" + sectionId.toString();m_sections.put(sectionKey, newSection);m_chSections.add(sectionKey);196 <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!