Hi everybody,
I got a problem when loading my roster presence. I m using BOSCH Strophe.js and an Openfire server (3.8.x)
I call my roster using this stanza, and it’s work perfectly :
1
2
3
iq = $iq({type: ``'get'``}).c(``'query'``, {xmlns: ``'jabber:iq:roster'``});
connection.sendIQ(iq, getRoster);
1
2
3
4
5
6
7
8
9
10
11
function
getRoster(iq){
``$(iq).find(``'item'``).each(``function``(){
``var
jid = $(``this``).attr(``'jid'``); ``// The jabber_id of your contact
``// You can probably put them in a unordered list and and use their jids as ids.
``$(``'#online'``).children(``'ul'``).append(``'<li id="'``+jid+``'"><a href="#" class="online_member"><img src="images/Offline.png" class="status"><p>'``+jid+``'</p></a></li>'``);
``});
``connection.addHandler(on_presence, ``null``, ``"presence"``);
``connection.send($pres());
}
Now, I want to load the users presence, to change their color and permit them to chat.
To make it work, I ve found a code on google :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function
on_presence(presence){
``var
presence_type = $(presence).attr(``'type'``); ``// unavailable, subscribed, etc...
``var
from = $(presence).attr(``'from'``); ``// the jabber_id of the contact
``if
(presence_type != ``'error'``){
``if
(presence_type === ``'unavailable'``){
``alert(``'offline'``);
``}``else``{
``var
show = $(presence).find(``"show"``).text(); ``// this is what gives away, dnd, etc.
``if
(show === ``'chat'
|| show === ``''``){
``alert(``'online'``);
``}``else``{
``// etc...
``alert(``'etc'``);
``}
``}
``}
``//RETURN TRUE!!!!!!!!!
``return
true``;
}
Actually, it works for other people, but not for me. So I guess the problem is from my Openfire configuration.
In the console, I try to change the “subscription” property, but it generates an erreur on the java lib (null pointer exception), and I dont see any modification in the ofroster table on MYSQL. So I ve tried manually to change the value of ask, recv, and sub but not way, the presence is not managed.
On the other side, when I log an account twice, the presence is managed, I see the modification, and I can chat.
Any idea ?
Sorry for the bad english, I m a french student ^^’.
Thanks for all,
Skahrz