powered by Jive Software

Roster's presence issue in XIFF library

Hi All,

I have identified an issue in the XIFF library.I was working with the IMGateway and creating an application with that plugin. I have found that when a users login his roster’s presence is not reflected correctly. Some of the roster’s presence was missing.

Issue Description

  • Roster’s presence was not getting updated correctly as and when you login.

Analysis

  • When a user login and request for his rosters list. openfire sends the presence-packets of the rosters after sending the roster-packet.
  • Now those presence packets are send in bunch, and XIFF library code is written such a way that it can handle an array of presence packets. below is the actual code which is doing that (Code snipet from org.jivesoftware.xiff.im.Roster.as )
private function handlePresences( presenceArray:Array):void
        {
            for each(var aPresence:Presence in presenceArray)
            {
                ........
                ........
                ........
            }
        }
  • When i was debugging this issue, i found that the code was acually processing only the first presence packet of the presence-array. and rest all is discarded. Thats why the presence of some roster are not processed by xiff.

Fix

  • In the handlePresences() method, there are two places where “return;” statements are being used.

    Actual Code

.........
    .........
    if(!unavailableItem) return;
    updateRosterItemPresence( unavailableItem, aPresence );     ........
    ........     if(!availableItem) return;
    updateRosterItemPresence( availableItem, aPresence );     ........
    ........
**Fix** : Removed the return statements
.........
    .........
    if(unavailableItem)
        updateRosterItemPresence( unavailableItem, aPresence );     ........
    ........     if(availableItem)
        updateRosterItemPresence( availableItem, aPresence );     ........
    ........