How to format xmpp presence stanza to join a MUC room

懵懂的女人 提交于 2019-12-11 19:28:25

问题


I'm trying to figure out how to format a presence stanza being sent to a room, and I'm not following the examples I've found online.

presence_stanza = f"<presence xmlns='jabber:client' from='{user_id}@conference.domain.com/{what_goes_here} to='{room_id}@conference.domain.com'/>"

In particular I'm unsure what the ID/string that follows the / in the from address.

For reference:

https://www.ejabberd.im/node/5189/index.html

Ejabberd not sending presence stanza to other roster members


回答1:


You should read the Multi-User chat specification, especially the part that describes how to enter the room: https://xmpp.org/extensions/xep-0045.html#enter

The spec example is well commented.

You do not even need to set the from. The server will set it for you to your current session full JID. The to needs to be a full JID including indeed the room_id, but also the nickname of your user in the room. It should be something like:

<presence to='{room_id}@conference.domain.com/{user_nick_in_the_room}'/>


来源:https://stackoverflow.com/questions/56464533/how-to-format-xmpp-presence-stanza-to-join-a-muc-room

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