有人可以指导我如何使用strophe.js检索OpenFire中所有可用房间的列表。我没有发现与此主题相关的任何非常有用的东西。谢谢
我花了几个小时来找到解决方案,但比预期要容易。我将添加代码的这一部分,因此可能有人将来需要它。
getListRooms = function(server){
var iq;
iq = $iq({
to: server,
from: connection.jid,
type: "get"
}).c("query", {
xmlns: Strophe.NS.DISCO_ITEMS
});
connection.sendIQ(iq.tree(), function (iq) {
console.log(iq);
if (!iq || iq.length == 0)
return;
//jquery load data after loading the page.This function updates data after jQuery loading
$rootScope.$apply(function () {
$(iq).find("item").each(function () {
//your function to update
});
});
console.log('success, all rooms received'); }, function (err) { console.log('error, something went wrong with rooms receivig', err); });
}