openfire获取在线用户

发布于 2024-11-27 04:42:38 字数 406 浏览 2 评论 0原文

我使用 OpenFire 服务器进行即时消息传递,并在客户端使用 JSJaC JavaScript 库。我是 XMPP 技术的新手。
我想要的是加载时我想发送用户列表并接收每个用户的状态。类似这样

$(function(){
    var UserList = ["Isis", "Jackob", "Oybek"];
    con.send(UserList, OnComplete);
});


function OnComplete(myList){
    for (el in myList)
        if (el.IsOnline) {
            // Do DOM Stuff
        }
}

可能吗?
我一直在寻找文档、示例和其他类似的回复,但没有找到任何内容。

I'm using OpenFire server for instant messaging and JSJaC JavaScript library on the client. I'm new in XMPP technology.
What I want is on load I want to send a list of users and receive status for each. Something like

$(function(){
    var UserList = ["Isis", "Jackob", "Oybek"];
    con.send(UserList, OnComplete);
});


function OnComplete(myList){
    for (el in myList)
        if (el.IsOnline) {
            // Do DOM Stuff
        }
}

Is it possible?
I've been looking for the documentation, examples and other similar responses but didn't find anyting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傾城如夢未必闌珊 2024-12-04 04:42:38

您无法查询是否存在。您可以订阅状态。如果您发送自己的状态信息,服务器将向您发送您订阅的每个人的当前状态信息,以及从那时起他们对其状态状态所做的每项更改。无法判断您何时“完成”获得存在,因为你永远不会完成。只需设置一个回调,以便在您订阅的人的状态发生变化时执行一些有趣的操作,这样您就会处于良好状态:

con.registerHandler('presence_in', function(p) { 
    var from = p.getFromJID()
    // do something interesting with p, from, etc.
});

You can't query for presence. You can subscribe to presence. If you send your own presence in, the server will send you the current presence of everyone you have subscribed to, as well as every change they make to their presence from there on in. There's no way to tell when you're "done" getting presence, because you're never done. Just set up a callback to do something interesting whenever you get a presence change from the person you are subscribed to, and you'll be in good shape:

con.registerHandler('presence_in', function(p) { 
    var from = p.getFromJID()
    // do something interesting with p, from, etc.
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文