开发者

openfire get online users

开发者 https://www.devze.com 2023-03-23 08:47 出处:网络
I\'m using OpenFire server for instant messaging and JSJaC JavaScript library on the client. I\'m new in XMPP technology.

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", 开发者_StackOverflow"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.


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.
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号