I'm using the Strophe.js Roster plugin with Ejabberd as XMPP Server. When I use Adium or some other XMPP Clients I can add some other accounts in my Roster. When I send an invitation, the other account receives presence with type=='subscribe'
.
Wit Strophe.js Roster, I never receive any presence with type == 'subscribe'
!
I tried everything...I added some handlers...I "filtered" and ...
Here is my code :
HTML includes
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
<script src='../strophe.js'></script>
<script src="../strophe.muc.js"></script>
<script src="../strophe.register.js"></script>
<script src="../strophe.roster.js"></script>
<script src='my-code.js'></script>
my-code.js
var jid;
$(document).ready(function () {
connection = new Strophe.Connection(BOSH_SERVICE, {'keepalive': true});
//connection.rawInput = rawInput;
//connection.rawOutput = rawOutput;
connection.addHandler(onPresence, null, 'presence', null, null, null);
connection.roster.registerRequestCallback(onRequest);
// Manage connection
try {
$('#connect').get(0).value = 'disconnect';
connection.restore(null, onRegister);
} catch(e) {
if (e.name !== "StropheSessionError") { throw(e); }
$('#connect').get(0).value = 'connect';
}
$('#connect').bind('click', function () {
var button = $('#connect').get(0);
if (button.value == 'connect') {
button.value = 'disconnect';
jid = $('#jid').get(0).value;
connection.connect(jid, $('#pass').get(0).value, onConnect, 10);
} else {
button.value = 'connect';
connection.disconnect();
}
});
});
function onPresence(stanza)
{
log("PRESENCE");
console.log(stanza);
return true;
}
function onRequest(req) {
console.log("Request");
console.log(req);
return true;
}
Am I missing something?
I solved my problem!