Dear Sir,
I have written the following code, which works perfectly fine and gives me the buddy/roster list for a particular user on the debugger window. Iam able to see the prescence of persons in the buddy list as they come and go online and offline, as I said on the debugger window. I would like to if there is any I can display the buddy/roster list and their prescence for a particular user on the command prompt.
import org.jivesoftware.smack.*;
import java.util.*;
public class TestLoginadmin {
public static void main(String [] args) throws Exception {
XMPPConnection.DEBUG_ENABLED = true;
String server = “128.*..***”;
XMPPConnection con = new XMPPConnection(server);
final Roster roster = con.getRoster ();
if (con.isConnected())
{
System.out.println (“at -” server"- connected");
con.login(“admin”, “abc123”);
System.out.println (“Roster For Admin is :”);
for (Iterator i=roster.getEntries(); i.hasNext(); )
{
System.out.println(i.next());
}
System.out.println (“Connected as Admin to view roster presence”);
}
else
{
System.out.println(“not connected with -“server””);
}
//ADDING a Roster Listener
roster.addRosterListener
(
new RosterListener()
{
public void rosterModified()
{
// Ignore event for this example.
}
public void presenceChanged(String user)
{
// If the presence is unavailable then “null” will be printed,
// which is fine for this example.
System.out.println("Presence changed: " + roster.getPresence(user));
}
}
);
}//end of Main
}// end of TestLogin
This is what I get on the command prompt when i run the program…
at -128.*..***- connected
Roster For Admin is :
Connected as Admin to view roster presence
Presence changed: available: available
Presence changed: null
this is when one of the persons in my buddy list logg’'s in and loggs out . I would like to display the name of the user in my buddy list at the command prompt.
Hoping that some one will help me.
Thanking you
Sincerely
rvenkat