无法获取使用asmack加入聊天室 [英] Unable to get Joined Chat Rooms using asmack

查看:590
本文介绍了无法获取使用asmack加入聊天室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我没有能够获得参加聊天室。我使用的Openfire服务器3.8.2和asmack库asmack-Android的16.jar。我收到的时候我叫getJoinedRooms功能项未找到错误。虽然我可以看到用户在房间从管理控制台连接。它是服务器问题还是客户问题或asmack一些问题?请告诉我,如果有人能够得到使用的Openfire和asmack为Android加入了聊天室。

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");

我也试过,但它没有给出回应形式的服务器:
    迭代RoomsIterator = MultiUserChat.getJoinedRooms(MyService.getConnection(),user@192.168.1.3/Smack);

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.

推荐答案

我解决我的问题通过增加一个数据包监听通话后得到加入房间的功能。由于我得到了一个空列表,但是当我调试我检查室在被我因此运行asmack的getjoinedroom功能服务器发送生成的XML Stanze酒店已被退回,然后我手动添加公顷数据包监听器是这样的:

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);

}

这篇关于无法获取使用asmack加入聊天室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆