3
votes

I'm creating a messenger using XMPP. I did connect to openfire server successfully.

Console log also received 'connecting' and 'connected' status, but I checked session on openfire admin console:

Name : Anonymous
Resource : some values
Node : Local
Status : Authenticated
Presence : Offline

If I use spark client program, it changed presence to Online status.

How can I change that? Should I add more code to lines?

var jid = 'id';
var pw = 'testpw';
var BOSH_SERVICE = 'http://127.0.0.1:7070/http-bind/';
var connection = null;

connection = new Strophe.Connection(BOSH_SERVICE);
connection.connect(jid, pw, callback);

function callback(status){
    console.log(status);
}
2

2 Answers

4
votes

To declare your Presence Status you have to add these lines in the callback function:

if (status == Strophe.Status.CONNECTED) {
    connection.send($pres());
}

If you need a web client example based on XMPP (using Strophe.js) check my Plunker below:

http://plnkr.co/edit/EhQHDsYpDhrECmaaIlZO

0
votes

Added send($pres())

if(status === Strophe.Status.CONNECTED){
    connection.send($pres());
    console.log('connected');
}

enter image description here

Just can see connecting

And not added send($pres())

if(status === Strophe.Status.CONNECTED){
    console.log('connected');
}

enter image description here

can see connecting and connected log