Dual-Login
You should use this method if you have already a login in your website.
<form id="form"> <input type="text" id="username" /> <input type="password" id="password" /> <input type="submit" value="Submit" /> </form> <button id="logout">Logout</button>
jsxc.init({
loginForm: {
form: '#form',
jid: '#username',
pass: '#password'
},
logoutElement: $('#logout'),
loadSettings: function() {
return xmpp: {
url: '/http-bind/',
domain: 'localhost',
resource: 'example',
overwrite: true,
onlogin: true
};
},
root: '/jsxc/'
});
AJAX Login
Do you want to login directly within your script? Choose this type.
<input type="text" id="username" /> <input type="password" id="password" /> <button id="submit">Log in</button>
jsxc.init({
xmpp: {
url: '/http-bind/'
},
root: '/jsxc/'
});
$('#submit').click(function(){
var username = $('#username').val();
var password = $('#password').val();
var jid = username + '@localhost';
jsxc.start(jid , password);
});
Box Login
Do you look for a discrete login method? Choose this.
<button id="button">Open Box</button>
jsxc.init({
loadSettings: function() {
return xmpp: {
url: '/http-bind/',
domain: 'localhost',
resource: 'example',
overwrite: true,
onlogin: true
};
},
root: '/jsxc/'
});
$('#button').click(jsxc.gui.showLoginBox);
Prelogin
Attach to existing BOSH connection. Helpful if you login server side.
jsxc.init({
xmpp: {
url: '/http-bind/',
jid: 'username@localhost',
sid: 'SID',
rid: 'RID'
},
root: '/jsxc/'
});
AJAX Prelogin
Attach to existing BOSH connection after JSXC was initialized.
jsxc.init({
xmpp: {
url: '/http-bind/'
},
root: '/jsxc/'
});
function callback() {
jsxc.start('username@localhost', 'SID', 'RID');
}