Xmpp chat invisible presence

╄→гoц情女王★ 提交于 2019-12-06 13:36:05

问题


I'm building a bot that monitor friends presences but doesn't need to be visible. I have tried to set presence using priority, show, type with all knowns values but without success. Is possibile to be invisibile and just receive presence notifications?

Thanks!


回答1:


See XEP-0126: Invisibility, section 3.1:

<iq from='bilbo@tolkien.lit/shire' type='set' id='inv1'>
  <query xmlns='jabber:iq:privacy'>
    <list name='invisible'>
      <item action='deny' order='1'>
        <presence-out/>
      </item>
    </list>
  </query>
</iq>



回答2:


Have a look at the rfc. Presence has a subscription status. If your bot is subscribed to receive presence from your users but your users are not, they are not going to be notified of the bot's presence.

In other words, your bot should send:

<presence to="user@example.com" type="subscribe" />

followed by the user's authorization,

<presence to="bot@example.com" type="subscribed" />

Now the bot will receive presence from the user, but not the opposite.




回答3:


To set status for become invisible, you must send a presence with type "invisible".

<presence type="invisible"/>

And here is the code (in ios):

XMPPPresence *presence = [XMPPPresence presenceWithType:@"invisible"];
[[self xmppStream] sendElement:presence];

I use this code to set my status as "invisible". For more details, please read the documentation on http://xmpp.org/extensions/xep-0018.html#sect-id86210




回答4:


Last I knew from Facebook, it's not possible to implement invisibility via XMPP commands: https://developers.facebook.com/bugs/315067461919373. See also https://developers.facebook.com/docs/chat/ under Limitations.



来源:https://stackoverflow.com/questions/10141155/xmpp-chat-invisible-presence

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!