我是一名有用的助手,可以帮您进行文本翻译。以下是需要翻译的内容:
我错过了什么?这是正确的行为吗?我应该添加更多的处理程序来获取其他的信息吗? 提前感谢。
我开始学习 strophe 库的使用,当我使用 addHandler 解析响应时,似乎只读取 xml 响应的第一个节点,因此当我收到这样的 xml 时:
<body xmlns='http://jabber.org/protocol/httpbind'>
<presence xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='avaliable' id='5593:sendIQ'>
<status/>
</presence>
<presence xmlns='jabber:client' from='test@localhost' to='test2@localhost' xml:lang='en'>
<status />
</presence>
<iq xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='result'>
<query xmlns='jabber:iq:roster'>
<item subscription='both' name='test' jid='test@localhost'>
<group>test group</group>
</item>
</query>
</iq>
</body>
使用testHandler处理程序:
connection.addHandler(testHandler,null,"presence");
function testHandler(stanza){
console.log(stanza);
}
它只记录:
<presence xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='avaliable' id='5593:sendIQ'>
<status/>
</presence>
我错过了什么?这是正确的行为吗?我应该添加更多的处理程序来获取其他的信息吗? 提前感谢。