Note
We use a Typescript-like syntax to describe our API. For example a following question mark means that this argument or property is optional.
You have to initialize JSXC with some options so it can learn about your environment. If you have already some established sessions, those will be restored.
options.appName?
(string)Name of container application (e.g. Nextcloud or SOGo).
Default:
"web applications"
options.lang?
(string)Default language.
Default:
"en"
options.autoLang?
(boolean)Auto language detection.
Default:
true
options.rosterAppend?
(string)Query string for element which should contain your contact list.
Default:
"body"
options.rosterVisibility?
("shown"|"hidden")Default roster visibility.
Default:
"shown"
options.hideOfflineContacts?
(boolean)Set to true if you want to hide offline contacts.
Default:
false
options.loadOptions?
(jid: string, password: string) => Promise<{[id: string]: {[key: string]: any}}>If you store option changes with
options.onOptionChange
you probably want to restore them on the next login. Just return an object with all id's and the corresponding values.Default:
undefined
options.loadConnectionOptions?
(username: string, password: string) => Promise<ISettings>This option can provide connection options for every form login (form watcher, login dialog).
Default:
undefined
options.onOptionChange?
(id: string, key: string, value: any, exportId: () => any) => voidThis function is called every time the user changes a option.
Default:
undefined
options.getUsers?
(search: string) => Promise<{[uid: string]: string}>If you like to provide auto suggestions if the user is adding a contact, you should add this function. Key has be a JID or UID and value a display name.
Default:
undefined
options.RTCPeerConfig.ttl?
(number)Time-to-live for config from url.
Default:
3600
options.RTCPeerConfig.iceServers?
(array)ICE servers like defined in http://www.w3.org/TR/webrtc/#idl-def-RTCIceServer;
Default:
[{ urls: 'stun:stun.stunprotocol.org' }]
options.onlineHelp?
(string)Default:
http://www.jsxc.org/manual.html
options.storage?
(localStorage|sessionStorage)Storage backend. Has to implement the Storage interface of the Web Storage API.
Default:
localStorage
options.disabledPlugins?
(array<string>)Default:
[]
options.connectionCallback?
((jid: string, status: number, condition?: string) => void)Default:
undefined
options.onUserRequestsToGoOnline?
(() => void)If the user requests to go online again, this function is called. Default: The login dialog is shown.
Default:
loginDialog
Number of restored connections.
With JSXC you can also continue a previous established BOSH session.
boshUrl
(string)- The URL of your BOSH service.
jid
(string)- Your Jabber Id with or without resource. E.g.
[email protected]
or[email protected]/desktop
.
sid
(string)- Your Session ID from your pre-bind session.
rid
(string)- Your Request ID from your pre-bind session.
Promise<void>
- Promise is resolved if the connection is established and the UI loaded.
Start a new connection with the given service and credentials.
boshUrl
(string)- The URL of your BOSH service.
jid
(string)- Your Jabber Id with or without resource. E.g.
[email protected]
or[email protected]/desktop
.
password
(string)- Corresponding password to your Jabber Id.
Promise<void>
- Promise is resolved if the connection is established and the UI loaded.
Show an empty contact list which allows the user to connect to a service by itself.
Promise<void>
- Promise is resolved if the UI is loaded.
Same as jsxc.start
, but just connects to the XMPP and stops afterwards. Can be used to connect before a form is submitted, or similar.
Promise<void>
- Promise is resolved if the connection is established.
Watch a login form and use credentials to establish an XMPP connection. You can
provide options with options.loadConnectionOptions
.
formElement
(JQuery)- Form element which should be watched for a submit event.
usernameElement
(JQuery)- If the form is submitted get the username from this element.
passwordElement
(JQuery)- If the form is submitted get the password from this element.
Watch a logout element and disconnect JSXC before the original click action is processed.
element
(JQuery)- Logout element which should be watched for a click event.
Opens a login modal with field for username and password.
username?
(string)- Username for login can be predefined.
Disconnect all accounts.
Promise<void>
- Promise is resolved if all accounts are disconnected.
Add a new entry to the main menu.
options.id
(string)- ID of your menu entry.
options.handler
((ev) => void)- This handler is called if the user clicks on the menu entry.
options.label
(string)- Every menu entry needs a text label.
options.icon?
(string)- If you provide a URL or Base64 encoded image, an icon is shown beside the label.
options.offlineAvailable?
(boolean)- If your entry should also be clickable while the user is offline, set this to
true
. Default:false
Show or hide the contact list.
Enable debug mode for more log messages.
Disable debug mode.
Delete all data stored by JSXC in your data backend.
Warning
This function is only available in debug mode.
number
- Number of deleted items.
uid
(string)- UID of account. Usually the bare jid.
Account
- Account object.
jid
(string)- Bare JID of contact.
Contact|MultiUserContact
- Depending on the kind of user, a contact or multi-user contact is returned.
Creates a new MUC room.
jid
(string)- Bare JID of new multi-user contact.
nickname
(string)- Desired nickname in MUC room.
displayName?
(string)- Contact name in roster.
password?
(string)- Protect room with password.
MultiUserContact
- Multi-user contact is returned.
Opens the chat window.
Opens the chat window and highlights it.
Adds contact to roster or bookmark storage.
Join the given room.
Leave the given room.
Destroy the given room.
JSON
- Room configuration form as json.
form
(JSON)- The filled room configuration form previously retrieved via
multiUserContact.getRoomConfigurationForm()
.
service
(string)- The URL of your BOSH service.
domain
(string)- Register a new user with this domain.
callback?
((form: Form) => Promise<Form>)- If you like to display a custom form, provide a callback.
Promise<void>
- Promise is resolved if the user was successfully registered.
Allows you test if a BOSH server is reachable and serving the given domain.
url
(string)- URL which you like to test.
domain
(string)- Domain which you like to test.
Promise<string>
If the BOSH server is reachable the promise resolves with a constant success string.
In the error case the promise is resolved with an error object. You can call
toString()
to get the error message in english orgetErrorCode()
to get a more generic error code. You find a list of all messages and codes insrc/api/v1/testBOSHServer.ts
.
Shows the current version of JSXC.
string
- Version number of JSXC.