离线用户和经销商接受好友请求使用的Andr​​oid

离线用户和经销商接受好友请求使用的Andr​​oid

本文介绍了检查的Openfire的在线/离线用户和经销商接受好友请求使用的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Openfire服务器机器人。现在,我需要检查有多少用户在线和他们是谁。我的连接正常。但是,当我检查它的输出是什么样子,


时调用名册条目的presence更改

名称:埃斯蒂

状态:不可用

时调用名册条目的presence更改

名称:罗尼

状态:不可用


那么如何确认谁是在线还是离线。另一个问题是如何自动接受请求。
请我需要帮助。

public void OnlineUser()
{

    final Roster sroster = connection.getRoster();

    try {
        sroster.createEntry("esty", "roni", null);
    } catch (XMPPException e) {

        e.printStackTrace();
    }


     Presence presence = new Presence(Presence.Type.available);
     connection.sendPacket(presence);
 //  context.setConnection(Constants.connection);

    // final Roster roster =connection.getRoster();
     final Collection<RosterEntry> entries = sroster.getEntries();

    sroster.addRosterListener(new RosterListener() {
         @Override
         public void presenceChanged(Presence presence) {
           //Called when the presence of a roster entry is changed
             for (RosterEntry entry : entries) {



                    Log.v("roni", "Called when the presence of a roster entry is changed ");
                         Presence entryPresence = sroster.getPresence(entry.getUser());

                         Presence.Type type = entryPresence.getType();
                         uName =entry.getName().toString();
                         uStatus=type.toString();
                         Log.v("roni", "Name: " + entry.getName().toString());
                         Log.v("roni", "Status: " +type.toString());

                 }
         }
         @Override
         public void entriesUpdated(Collection<String> arg0) {
           // Called when a roster entries are updated.
             for (RosterEntry entry : entries) {


                    Log.v("roni", "Called when a roster entries are updated ");
                         Presence entryPresence = sroster.getPresence(entry.getUser());

                         Presence.Type type = entryPresence.getType();
                         uName =entry.getName().toString();
                         uStatus=type.toString();
                         Log.v("roni", "Namne: " + entry.getName().toString());
                         Log.v("roni", "Status: " +type.toString());

                 }
         }
         @Override
         public void entriesDeleted(Collection<String> arg0) {
           // Called when a roster entries are removed.
             for (RosterEntry entry : entries) {


                    Log.v("roni", "Called when a roster entries are removed. ");
                         Presence entryPresence = sroster.getPresence(entry.getUser());

                         Presence.Type type = entryPresence.getType();
                         uName =entry.getName().toString();
                         uStatus=type.toString();
                         Log.v("roni", "Namne: " + entry.getName().toString());
                         Log.v("roni", "Status: " +type.toString());

                 }
         }
        @Override
         public void entriesAdded(Collection<String> arg0) {
           // Called when a roster entries are added.
            for (RosterEntry entry : entries) {


                Log.v("roni", " Called when a roster entries are added. ");
                     Presence entryPresence = sroster.getPresence(entry.getUser());

                     Presence.Type type = entryPresence.getType();
                     uName =entry.getName().toString();
                     uStatus=type.toString();
                     Log.v("roni", "Namne: " + entry.getName().toString());
                     Log.v("roni", "Status: " +type.toString());

             }
         }
        });
解决方案

Are you using it with LDAP? If so, you can go into Users/Groups and then select a group. If you enable Contact list group sharing it should do the trick.

"Enable contact list group sharing".See my screenshot for details:

Hope it will solve your problem.

这篇关于检查的Openfire的在线/离线用户和经销商接受好友请求使用的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 22:04