QuickBlox 2.0聊天对话框 - 如何检测用户加入或者离开群聊对话? [英] QuickBlox 2.0 Chat dialog - how to detect an user join or leave group chat dialog?

查看:213
本文介绍了QuickBlox 2.0聊天对话框 - 如何检测用户加入或者离开群聊对话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有QuickBlox麻烦时,从更新版本1.2.4到2.0版本。

在2.0版本中如何检测用户加入或者离开群聊对话?

在1.2.4版本我使用ParticipantListener但2.2版QBGroupChat不能没有增加这个监听器?

感谢在前进。

版本1.2.4:

  PacketListener participantListener =新PacketListener(){    @覆盖
    公共无效processPacket(分组数据包){
        presence presence =(presence)数据包;        如果(presence.getType()== presence.Type.available){
            //用户进入房间        }否则如果(presence.getType()== presence.Type.unavailable){
            //用户离开了房间        }    }
};


解决方案

下面是如何利用QBParticipantListener 2.1版本:

 私人QBParticipantListener participantListener;participantListener =新QBParticipantListener(){
    @覆盖
    公共无效过程presence(QBGroupChat群聊,QB presence presence){    }
};私人QBGroupChat currentChatRoom = ...;
currentChatRoom.addParticipantListener(participantListener);

http://quickblox.com/developers/Android_XMPP_Chat_Sample#Get_online_users

I have trouble with QuickBlox when update from version 1.2.4 to version 2.0.

In version 2.0 how to detect a user join or leave group chat dialog?

In version 1.2.4 i use ParticipantListener but version 2.2 QBGroupChat cant not add this listener ?

Thank in advance.

Version 1.2.4:

PacketListener participantListener = new PacketListener() {

    @Override
    public void processPacket(Packet packet) {
        Presence presence = (Presence) packet;

        if (presence.getType() == Presence.Type.available) {
            // user entered the room

        } else if (presence.getType() == Presence.Type.unavailable) {
            // user left the room

        }

    }
};

解决方案

Here is how to use QBParticipantListener for version 2.1:

private QBParticipantListener participantListener;

participantListener = new QBParticipantListener() {
    @Override
    public void processPresence(QBGroupChat groupChat, QBPresence presence) {

    }
};

private QBGroupChat currentChatRoom = ...;
currentChatRoom.addParticipantListener(participantListener);

http://quickblox.com/developers/Android_XMPP_Chat_Sample#Get_online_users

这篇关于QuickBlox 2.0聊天对话框 - 如何检测用户加入或者离开群聊对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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