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.

Example 8-10 userEntered and userLeft event handlerspublic void usersEntered(SectionEvent event) {UserInPlace[] users = event.getEnteredUsers();;for (int i = 0; i < users.length; i++) {m_usersInPlace.put(users[i].getMemberId(), users[i]);m_userQueue.add(users[i].getMemberId());NoActionUserInPlaceListener nal = null;users[i].addUserInPlaceListener(nal = newNoActionUserInPlaceListener());m_userListeners.put(users[i].getMemberId(),nal );}}if (m_userQueue.size() == 1) {this.notifyMember(users[0].getMemberId());}public void userLeft(SectionEvent event) {UserInPlace userInPlace = event.getDepartedUser();m_usersInPlace.remove(userInPlace.getMemberId());m_userListeners.remove(userInPlace.getMemberId());if (m_userQueue.elementAt(0) == userInPlace.getMemberId()) {m_userQueue.remove(0);if (m_userQueue.size() >= 1) {this.notifyMember((Integer) m_userQueue.elementAt(0));}} else {m_userQueue.remove(userInPlace.getMemberId());}}8.5.6 Receiving, translating, and responding to questionsWhen a user in the Queue sends a question to the panel, they are actuallysending a message to the custom activity in our server application. The messagewill trigger the textReceived() event the ActivityHandler class. The code first getthe senders display name and language from their user attributes. Next, it gets alist of all the country sections. (The list does not include the stage, Lobby orQueue.) For each section, it grabs the defined language for the section, thentranslates it and sends it to the section. Then it performs the same process for allusers in the Queue. Finally, it translates the message into English and sends it tothe panel section.Example 8-11 on page 214 shows the code used in the textReceived() event.Chapter 8. Places and Place awareness 213

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

Saved successfully!

Ooh no, something went wrong!