XMPP presence认购 [英] XMPP presence Subscription

查看:162
本文介绍了XMPP presence认购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,当我把这个使用code请求任何朋友。

In my application when I send a request to any friend using this code..

try {               
                roster.createEntry(idExtension, nickname, null);
                roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
                Presence subscribe = new Presence(Presence.Type.subscribe);
                subscribe.setTo(idExtension);               
                connection.sendPacket(subscribe);


                return true;
            } catch (XMPPException e) {
                System.err.println("Error in adding friend");
                return false;
            }

然后订阅说,在双方的朋友名册无。

then the subscription says "NONE" in both the friends rosters.

但应TO和FROM

但如果出于同样的过程中,我用这个code -

But if For the same process I use this code -

try {               
                roster.createEntry(idExtension, nickname, null);
                roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
                Presence subscribed = new Presence(Presence.Type.subscribed);
                subscribed.setTo(idExtension);              
                connection.sendPacket(subscribed);


                return true;
            } catch (XMPPException e) {
                System.err.println("Error in adding friend");
                return false;
            }

然后,它给了我正确的结果,我应该在previous情况。

Then it gives me right result which i should get in the previous case.

请告诉我为什么我没有收到相同的订阅模式。

Please tell me why I am not getting the same in SUBSCRIBE mode.

感谢

推荐答案

我想你没有得到类型的含义,presence。

I guess you are not getting the meaning of type in Presence.

订阅 - 发送者希望订阅到收件人的   presence。

subscribe -- The sender wishes to subscribe to the recipient's presence.

订阅 - 发送者已经允许接收者   收到他们的presence。

subscribed -- The sender has allowed the recipient to receive their presence.

所以,当你发送的第一个你请求用户让你订阅了presence事件,直到他已经不允许你这样做的订阅类型为无。

So when you send the first one you request a user to let you subscribe to his presence events and until he has not allowed you to do so the subscription type is none.

在第二种情况下,你允许用户订阅您的presence,那就是你给他的权限来听你的presence,因此你得到的订阅类型。

In second case you allowed the user to subscribe to your presence, that is you give him permission to listen to your presence, and thus you get the subscription type.

这篇关于XMPP presence认购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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