JSXC example

This example demonstrates different types of login methods for JSXC. You find further information in our wiki.

You are testing JSXC in version .

You can use demo0 to demo9 with password demo0 to demo9 to test JSXC (XMPP domain: demo.jsxc.ch, BOSH url: /http-bind/).

Advanced controls

Delete all Data Enable Debug Mode Disable Debug Mode

Normal Layout Two Columns Layout Fullscreen Layout

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();

let formElement = $('#form');
let usernameElement = $('#username');
let passwordElement = $('#password');

function getSettings(username, password) {
  return Promise.resolve({
    xmpp: {
      url: '/http-bind/',
      domain: 'localhost',
    }
  });
}

jsxc.watchForm(formElement, usernameElement, passwordElement, getSettings);

Instant 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();

$('#submit').click(function(){
  let username = $('#username').val();
  let password = $('#password').val();

  let url = '/http-bind/';
  let jid = username + '@localhost';

  jsxc.start(url, jid , password);
});

Prelogin

Attach to existing BOSH connection after JSXC was initialized.

jsxc.init();

let url = '/http-bind/';
let jid = 'username@localhost';
let sid = 'YOUR_SID';
let rid = 'YOUR_RID';

jsxc.start(url, jid, sid, rid);