Question

My problem is i am not been able to receive joined chat rooms. I am using the openfire server 3.8.2 and asmack library asmack-android-16.jar. I receive item-not-found error when i call getJoinedRooms function. though i can see the user is joined in the room from the admin console. Is it the server problem or the client problem or some issue with asmack? Please tell me if someone is able to get joined chat rooms using openfire and asmack for android.

here is how i am call the function:

Iterator RoomsIterator=MultiUserChat.getJoinedRooms(MyService.getConnection(),"user@192.168.1.3");

i also tried this but it gives no response form server: Iterator RoomsIterator=MultiUserChat.getJoinedRooms(MyService.getConnection(),"user@192.168.1.3/Smack");

Please help me with my problem Thanks in advance.

Was it helpful?

Solution

I solved my problem by adding a packet listener after call get joined rooms function.. as i was getting an empty list but when i debug i check that the rooms was getting returned in the resultant xml stanze that was sent by the server therefore i run the getjoinedroom function of asmack and then i manually add ha packet listener like this:

public void AddPacketListener(){
PacketFilter filter = new IQTypeFilter(IQ.Type.RESULT);
MyService.getConnection().addPacketListener(new PacketListener() 
{   
public void processPacket(Packet paramPacket) {

if(paramPacket.getFrom().equals(MyService.getConnection().getUser())){
        String xml=paramPacket.toXML();
        String from[];

        System.out.println(xml);
        from=paramPacket.getFrom().split("/");
            Pattern pattern = Pattern.compile("<item jid=\"(.*?)/>");
            Matcher matcher = pattern.matcher(xml);
            String parts[];

            Roomlist.clear();
            while (matcher.find()) {    

                parts=matcher.group(1).split("@");
                Roomlist.add(parts[0]);

            }      
            return;         
            }

}
},filter);

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top