我正在将Strophe.js和MUC插件一起使用。我在浏览器中以“代理”身份连接,并使用外部python脚本将“代理”添加到房间。该应用程序的工作方式是这样的,后端会将连接的用户添加到某些会议室,但是前端需要知道将消息发送到哪里。
def add_user_to_room(user_name, room_name):
command = 'subscribe_room'
url = '{}/{}/{}'.format(base_url, api, command)
data = {
"user": add_host(user_name)+'/180062769060911144972260',
"nick": add_host(user_name),
"room": room_name + '@' + muc_service,
"nodes": "urn:xmpp:mucsub:nodes:messages,urn:xmpp:mucsub:nodes:affiliations,urn:xmpp:mucsub:nodes:subscribers"
}
response = requests.post(url, json=data)
print('Got result code {} with text {}'.format(response.status_code, response.text))
return response.status_code, response.text
这是我在套接字中得到的响应:
<message xmlns='jabber:client' to='agent@chat.domain.com/6665193359253278721998' from='agent@chat.domain.com'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='urn:xmpp:mucsub:nodes:subscribers'>
<item id='8698546583380897793'>
<subscribe jid='agent@chat.domain.com' nick='agent@chat.domain.com' xmlns='urn:xmpp:mucsub:0'/>
</item>
</items>
</event>
</message>
当外部脚本将用户添加到某个房间时,是否可以通过浏览器获取房间名称?