Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  IBM Sametime Forum

IBM Sametime Forum

developerWorks

  

PreviousPrevious NextNext


Amar Das 16.Apr.08 08:48 AM a Web browser
Sametime Connect Client 6.5.1 Windows


Hi:

I am working on a chat bot. User1 has User2 on its watch list. First User2 logs in the system. Then User1 logs in. But the userStatusChanged always report User2 as offline. Any clue why?

<code>
public class ChatBot implements LoginListener, ImServiceListener, ImListener, ResolveListener, StatusListener, AwarenessServiceListener {
......

/**
* Creates a sametime session
*
* @throws DuplicateObjectException
*/
public void stSession() throws DuplicateObjectException {
stsession = new STSession(sessionName);
stsession.loadSemanticComponents();
stsession.start();
logger.debug("Session created for " + userid);
stLogin(server, userid, password);
}

/**
* Logs into sametime
*
* @param server
* @param user
* @param password
*/
public void stLogin(String server, String user, String password) {
commService = (CommunityService) stsession
.getCompApi(CommunityService.COMP_NAME);
commService.addLoginListener(this);
commService.loginByPassword(server, user, password);
logger.debug("Attempting login to " + server);
}

public void loggedIn(LoginEvent le) {
logger.debug("Logged In");

// Attempt to set our status
try {
STUserStatus status = new STUserStatus(
STUserStatus.ST_USER_STATUS_ACTIVE, 0, STATUSMSG);
le.getLogin().changeMyStatus(status);
} catch (Exception exc) {
logger.debug("Exception caught - " + exc.getMessage());
}

// Register to listen for incoming messages
// We aren't concerned about failures so no need for a try/catch
imService = (InstantMessagingService) stsession
.getCompApi(InstantMessagingService.COMP_NAME);
imService.registerImType(ImTypes.IM_TYPE_CHAT);
imService.addImServiceListener(this);

// Get a handle to the Lookup Service and add a resolve listener
lookupService = (LookupService) stsession
.getCompApi(LookupService.COMP_NAME);
resolver = lookupService.createResolver(true, false, true, false);
resolver.addResolveListener(this);

// Get a handle to the Awareness Service and create a WatchList
awarenessService = (AwarenessService) stsession
.getCompApi(AwarenessService.COMP_NAME);
awarenessService.addAwarenessServiceListener(this);
watchList = awarenessService.createWatchList();
watchList.addStatusListener(this);

// add users to watched list
if (usersToWatch.size() > 0) {
String[] watched = usersToWatch.toArray(new String[usersToWatch
.size()]);
for (String user : watched) {
resolver.resolve(user);
}
}

public void userStatusChanged(StatusEvent se) {
// We get an array of objects representing the users
STWatchedUser[] users = (STWatchedUser[]) se.getWatchedUsers();
logger.debug("Number of watched users: " + users.length);
for (STWatchedUser stwu : users) {
logger.debug(stwu.getName() + " status changed to "
+ stwu.getStatus().getStatusType());
if (stwu.getStatus().getStatusType() == STUserStatus.ST_USER_STATUS_ACTIVE) {
// Send an alert the the user
logger.debug("Alert called for " + stwu.getName());

// Set the IM Type to IM_TYPE_CHAT
int imt = ImTypes.IM_TYPE_CHAT;

// Set the encryption level
EncLevel enc = EncLevel.ENC_LEVEL_ALL;

// Create the channel to the user
Im im = imService.createIm(stwu, enc, imt);
im.addImListener(this);
im.open();
}
}
}
</code>

Thanks in advance






User status is always offline (Amar Das 16.Apr.08)
. . Lookup changeMyStatus (Carl Tyler 16.Apr.08)





  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite