powered by Jive Software

When i delete a user why first it goes to entriesUpdated?

Hi,

I am using the below code and when i am deleting / removing a user first call comes to the “entriesUpdated” and then it goes to “entriesDeleted” and addresses has no object and can’t iterate.

I get the output as shown below. Why ---- UPDATE EVENT — is printing twice for delte caes?

---- UPDATE EVENT —
EntriesUpdated:kumarshivam.iiit\40gmail.com@gtalk.zenon153, shivam kumar
---- UPDATE EVENT —
EntriesUpdated:kumarshivam.iiit\40gmail.com@gtalk.zenon153, shivam kumar
---- DELETE EVENT —

This is working fine with the update case means when i change a contacts name. It’s coming once to the entriesUpdated() function.

---- UPDATE EVENT —
EntriesUpdated:syed.safvan\40gmail.com@gtalk.zenon153, safvan syed11

I have added the roster listener just after connection and login as shown below.

    rim.XMPPAddMessageListener(conn, rim);
        rim.XMPPAddPresenceListener(conn, rim);
        rim.XMPPServerLogin(conn, "user1", "test123");   
                   
        Roster roster = rim.XMPPCreateRosterConfig(conn,1);
       
        rim.XMPPCreateRosterListener(roster);

public void XMPPCreateRosterListener(Roster roster)
{
roster.addRosterListener(new RosterListener() {
public void entriesAdded(Collection addresses) {

            for (Iterator it = addresses.iterator(); it.hasNext();) {
                   String address = (String) it.next();
                   RosterEntry entry = connection.getRoster().getEntry(address);
                  
                   System.out.println("XMPPCreateRosterListener: entriesAdded -->" + entry.getUser());

                   //When the entry is only from the other user, then send a subscription request
                   if (entry != null && entry.getType() == RosterPacket.ItemType.from) {
                        try {
                             System.out.println("Creating entry to: " + entry.getUser());
                             connection.getRoster().createEntry(entry.getUser(), entry.getUser(), new String[0]);
                        } catch (XMPPException e) {
                             e.printStackTrace();
                        }
                   }
              }
        }
        public void entriesDeleted(Collection addresses)
        {
            System.out.println("---- DELETE EVENT ---");
           
            for (Iterator it = addresses.iterator(); it.hasNext();) {
                   String address = (String) it.next();
                   RosterEntry entry = connection.getRoster().getEntry(address);                      
                  
                   System.out.println("EntriesDeleted:" + entry.getUser() + ", " + entry.getName());                      
              }
        }
        public void entriesUpdated(Collection addresses)
        {
            System.out.println("---- UPDATE EVENT ---");
           
            for (Iterator it = addresses.iterator(); it.hasNext();) {
                   String address = (String) it.next();
                   RosterEntry entry = connection.getRoster().getEntry(address);                      
                  
                   System.out.println("EntriesUpdated:" + entry.getUser() + ", " + entry.getName());                      
              }                           
        }              
        public void presenceChanged(Presence presence)
        {               
            System.out.println("Presence changed: " + presence.getFrom() + ", " + presence+ "\n");
        }
    });
    }

Thnaks,

Samba