Reputation: 615
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);
}
Upvotes: 3
Views: 1139
Reputation: 615
Added send($pres())
if(status === Strophe.Status.CONNECTED){
connection.send($pres());
console.log('connected');
}
Just can see connecting
And not added send($pres())
if(status === Strophe.Status.CONNECTED){
console.log('connected');
}
can see connecting and connected log
Upvotes: 0
Reputation: 17647
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
Upvotes: 4