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: jsxc.ch, BOSH url: /http-bind/).

Advanced controls

Delete all Data Enable Debug Mode Disable Debug Mode

Normal Layout Two Columns Layout Fullscreen Layout

Dark Mode Light Mode

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>
let jsxc = new JSXC();

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

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

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

jsxc.watchLogoutClick(logoutElement);

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>
let jsxc = new JSXC();

$('#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.

let jsxc = new JSXC();

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

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