SleekXMPP Muc 房间列表和发现
SleekXMPP Muc Room List and Discovering
我是 XMPP 的新手 :) 我一直在使用 Ejabberd 和 sleekXMPP。
我的问题是如何使用 sleekXMPP 列出在线房间?
谢谢
我也为此苦苦挣扎了一段时间。列出房间不是 MUC 的一部分(xep_0045),而是服务发现的一部分(xep_0030) .
一些文档是here,但它仍然需要一些实验来找到'disco_items”数组键。注意“iterator”参数仅当您还加载 XEP-0059.
时才有效
它的工作原理如下:
确保您已加载 0030:
xmpp.register_plugin('xep_0030')
使用它:(在我的例子中,这是扩展 sleekxmpp.ClientXMPP 的 class 的 start() 方法的一部分)
result = self['xep_0030'].get_items(jid='conference.your.xmpp.server.com', iterator=True)
for room in result['disco_items']:
print "Found room %s, jid is %s" % (room, room['jid'])
Akom 有一个很好的方法,但我个人在迭代器参数方面遇到了问题。
服务发现实施的完整示例可在以下位置获得:
https://github.com/fritzy/SleekXMPP/blob/develop/examples/disco_browser.py
使用这些功能,您只需执行以下操作即可获取 XMPP 服务器的身份、信息和功能:
items = self['xep_0030'].get_items(jid='conference-server.com', node='', block=True)
然后:
for identity in info['disco_info']['identities']:
print(' - %s' % str(identity))
for feature in info['disco_info']['features']:
print(' - %s' % feature)
for item in items['disco_items']['items']:
print(' - %s' % str(item))
我是 XMPP 的新手 :) 我一直在使用 Ejabberd 和 sleekXMPP。 我的问题是如何使用 sleekXMPP 列出在线房间?
谢谢
我也为此苦苦挣扎了一段时间。列出房间不是 MUC 的一部分(xep_0045),而是服务发现的一部分(xep_0030) .
一些文档是here,但它仍然需要一些实验来找到'disco_items”数组键。注意“iterator”参数仅当您还加载 XEP-0059.
时才有效它的工作原理如下:
确保您已加载 0030:
xmpp.register_plugin('xep_0030')
使用它:(在我的例子中,这是扩展 sleekxmpp.ClientXMPP 的 class 的 start() 方法的一部分)
result = self['xep_0030'].get_items(jid='conference.your.xmpp.server.com', iterator=True) for room in result['disco_items']: print "Found room %s, jid is %s" % (room, room['jid'])
Akom 有一个很好的方法,但我个人在迭代器参数方面遇到了问题。
服务发现实施的完整示例可在以下位置获得:
https://github.com/fritzy/SleekXMPP/blob/develop/examples/disco_browser.py
使用这些功能,您只需执行以下操作即可获取 XMPP 服务器的身份、信息和功能:
items = self['xep_0030'].get_items(jid='conference-server.com', node='', block=True)
然后:
for identity in info['disco_info']['identities']:
print(' - %s' % str(identity))
for feature in info['disco_info']['features']:
print(' - %s' % feature)
for item in items['disco_items']['items']:
print(' - %s' % str(item))