Converse converse.js

Namespace: api

_converse.api

The private API

The private API methods are only accessible via the closured _converse object, which is only available to plugins.

These methods are kept private (i.e. not global) because they may return sensitive data which should be kept off-limits to other 3rd-party scripts that might be running in the page.

Source:

Namespaces

archive
chats
chatviews
connection
contacts
controlbox
disco
listen
omemo
promises
pubsub
rooms
roomviews
settings
tokens
user
vcard

Methods

(private, static) ping(jidopt)

Pings the service represented by the passed in JID by sending an IQ stanza.

Parameters:
Name Type Attributes Description
jid string <optional>

The JID of the service to ping

Source:

(static) send()

Allows you to send XML stanzas.

Source:
Example
const msg = converse.env.$msg({
    'from': 'juliet@example.com/balcony',
    'to': 'romeo@example.net',
    'type':'chat'
});
_converse.api.send(msg);

(static) sendIQ(stanza, timeout, reject) → {Promise}

Send an IQ stanza and receive a promise

Parameters:
Name Type Description
stanza XMLElement
timeout Integer
reject Boolean

Whether an error IQ should cause the promise to be rejected. If false, the promise will resolve instead of being rejected.

Source:
Returns:

A promise which resolves when we receive a result stanza or is rejected when we receive an error stanza.

Type
Promise

(static) trigger(name, …argumentopt, optionsopt)

Lets you trigger events, which can be listened to via _converse.api.listen.on or _converse.api.listen.once (see _converse.api.listen).

Some events also double as promises and can be waited on via _converse.api.waitUntil.

Parameters:
Name Type Attributes Description
name string

The event name

argument any <optional>
<repeatable>

Argument to be passed to the event handler

options object <optional>
Properties
Name Type Attributes Description
synchronous boolean <optional>

Whether the event is synchronous or not. When a synchronous event is fired, a promise will be returned by _converse.api.trigger which resolves once all the event handlers' promises have been resolved.

Source:

(static) waitUntil(condition) → {Promise}

Wait until a promise is resolved or until the passed in function returns a truthy value.

Parameters:
Name Type Description
condition string | function

The name of the promise to wait for, or a function which should eventually return a truthy value.

Source:
Returns:
Type
Promise