在名单中添加用户无效 [英] adding user in roster list isn't working

查看:74
本文介绍了在名单中添加用户无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的一对一聊天应用程序,已经完成了消息收发功能.现在,我试图向其他用户(例如在线/离线"等)显示用户的状态.为此,我必须使用Presence和Roster.但是我不知道在哪里以及如何使用它们,我的意思是完整的订阅请求流程,接受订阅后,用户的状态即在线/离线等.

I am creating an simple one to one chat app, I've done with the message send and receive. Now I am trying to show the status of the user to another(contacts) like "online/offline" etc. For that I have to use Presence and Roster.But I don't know where and how to use that, I mean the complete flow of subscription request and accept and after the subscription, the status of the users i.e. Online/Offline etc.

推荐答案

首先,您需要发送和接受联系请求

First of all you need to send and accept contact request

通过开火,您也可以从后端

步骤:首先点击用户/组>>点击用户名">>点击名册>>添加花名册

Steps : First click on Users/Groups >> click on "UserName" >> click on roster >> add roster

我在这里附上步骤屏幕

  • 点击添加新项

  • 添加花名册

  • add roster

编辑花名册并选择订阅

edit roster and select subscription both

然后您将使用此代码获得花名册列表

then after you will get roster list using this code

ArrayList<RosterEntry> rosterLists = new ArrayList<>();

 public List<RosterEntry> getFriendsList() throws SmackException.NotLoggedInException, InterruptedException, SmackException.NotConnectedException {
    rosterLists = new ArrayList<>();
    roster = Roster.getInstanceFor(Config.conn1);//connection object of AbstractXMPPConnection
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
        Log.e("Roster :", "Reload and wait");
    }

    Collection<RosterEntry> entries = roster.getEntries();
    Log.e("Size of Roster :", entries.size() + "");

    for (RosterEntry entry : entries) {
        rosterLists.add(entry);
        Log.d("Buddies", "Here: " + entry.toString());
        Log.d("Buddies", "User: " + entry.getUser());//get userinfo
        Log.d("Buddies", "User Name:" + entry.getName());//get username
        Log.d("Buddies", "User Status: " + entry.getStatus());//get status of user
    }
    listAdapter = new FriendUserListAdapter(UserListActivity.this, rosterLists);
    user_list.setAdapter(listAdapter);
    return rosterLists;
}

订阅类型与来源订阅之间有何区别?当任何用户添加漫游器与他/她联系时,在整个过程结束时,ofRoster(openfire)表的订阅状态将设置为来自".此过程的预期结果是两者"

what is the difference between subscription type both and from??? When any user add bot has his/her contact, then in the end of whole process, subscription status of ofRoster(openfire) table is set to ‘from’. The desired result of this process is ‘both’

这篇关于在名单中添加用户无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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