-
new Client(options)
createClient(options)
Client
Methodsclient.use(plugin)
client.on(event, [group], handler)
client.connect([opts])
client.disconnect()
client.sendIq(opts)
client.sendMessage(opts)
client.sendPresence(opts)
client.sendStreamError(opts)
- Keepalive
- Roster Management
- Service Discovery
- Jingle
- Pubsub
client.createNode(jid, node, [cb])
client.deleteNode(jid, node, [cb])
client.getItem(jid, node, id, [cb])
client.getItems(jid, node, opts, [cb])
client.publish(jid, node, item, [cb])
client.purgeNode(jid, node, [cb])
client.retract(jid, node, id, notify, [cb])
client.subscribeToNode(jid, opts, [cb])
client.unsubscribeFromNode(jid, opts, [cb])
- Multi-User Chat
client.ban(room, jid, reason, [cb])
client.changeNick(room, nick)
client.configureRoom(room, form, [cb])
client.directInvite(room, sender, reason)
client.discoverReservedNick(room, [cb])
client.getRoomConfig(jid, [cb])
client.getRoomMembers(room, opts, [cb])
client.getUniqueRoomName(jid, [cb])
client.invite(room, opts)
client.joinRoom(room, nick, opts)
client.kick(room, nick, reason, [cb])
client.leaveRoom(room, nick, opts)
client.requestRoomVoice(room)
client.setRoomAffiliation(room, jid, affiliation, reason, [cb])
client.setRoomRole(room, nick, role, reason, [cb])
client.setSubject(room, subject)
client.addBookmark(bookmark, [cb])
client.getBookmarks([cb])
client.removeBookmark(jid, [cb])
client.setBookmarks(opts, [cb])
- Message Syncing
- Other
client.deleteAccount([jid, cb])
client.getAccountInfo([jid, cb])
client.getAttention(jid, [opts])
client.getAvatar(jid, id, [cb])
client.getCommands(jid, [cb])
client.getPrivateData(opts, [cb])
client.getSoftwareVersion(jid, [cb])
client.getTime(jid, [cb])
client.getVCard(jid, [cb])
client.goInvisible([cb])
client.goVisible([cb])
client.markActive()
client.markInactive()
client.publishAvatar(id, data, [cb])
client.publishGeoLoc(data, [cb])
client.publishMood(mood, text, [cb])
client.publishNick(nick, [cb])
client.publishReachability(data, [cb])
client.publishTune(data, [cb])
client.publishVCard(vcard, [cb])
client.sendLog(jid, opts)
client.setPrivateData(opts, [cb])
client.updateAccount(jid, data, [cb])
client.useAvatars(data, [cb])
-
attention
auth:failed
auth:success
available
avatar
block
bosh:terminate
carbon:received
carbon:sent
chat:state
chat
connected
credentials:update
dataform
disco:caps
disconnected
geoloc
groupchat
id:ID
iq:get:NAME
iq:set:NAME
jingle:accepted
jingle:hold
jingle:incoming
jingle:localstream:added
jingle:localstream:removed
jingle:mute
jingle:outgoing
jingle:remotestream:added
jingle:remotestream:removed
jingle:resumed
jingle:ringing
jingle:terminated
jingle:unmute
message:error
message:sent
message
muc:available
muc:declined
muc:destroyed
muc:error
muc:invite
muc:join
muc:leave
muc:subject
muc:unavailable
nick
presence:error
presence
pubsub:event
raw:incoming
raw:outgoing
reachability
receipt[:ID]
replace[:ID]
roster:update
roster:ver
sasl:abort
sasl:challenge
sasl:failure
sasl:success
session:bound
session:end
session:error
session:started
stanza
stream:data
stream:end
stream:error
stream:management:enabled
stream:management:failed
stream:management:resumed
subscribe
subscribed
unavailable
unblock
unsubscribe
unsubscribed
Creates a new XMPP client instance, with no plugins loaded.
options
- An object with the client configuration as described in client options.
var XMPP = require('stanza.io');
var client = new XMPP.Client({
jid: '[email protected]',
password: 'hunter2'
});
An alternative method for creating a client instance.
Instantiating a client via this function will load all built-in plugins.
options
- An object with the client configuration as described in client options.
var XMPP = require('stanza.io');
var client = XMPP.createClient({
jid: '[email protected]',
password: 'hunter2'
});
When creating a client instance, the following settings will configure its behaviour:
-
jid
- (required) the requested bare JID for the client. password
- shortcut for settingcredentials.password
server
- specify the hostname of the server to initially connect to, if different fromjid.domain
.resource
- suggest a specific resource for this session.credentials
username
- username you're presenting for auth. Typically the local portion of the JID, but could be differentpassword
- just like it soundshost
- the domain of the serviceserverKey
- cached credential created bySCRAM-SHA-1
, that can be used without needing to know the passwordclientKey
- cached credential created bySCRAM-SHA-1
, that can be used without needing to know the passwordsaltedPassword
- cached credential created bySCRAM-SHA-1
, that can be used without needing to know the passwordserviceType
- for most cases should be'XMPP'
, the defaultserviceName
- for most cases should be the same as the'host'
, the defaultrealm
- for most cases should be the same as the'host'
, the defaultauthzid
-
transports
- a strings array of transport methods that may be used.wsURL
- URL for the XMPP over WebSocket connection endpoint.boshURL
- URL for the BOSH connection endpoint.sasl
- a list of the SASL mechanisms that are acceptable for use by the client.useStreamManagement
- set totrue
to enable resuming the session after a disconnect.rosterVer
- version ID of cached roster data given by the server, typically saved from a previous session.capsNode
- a URL for identifying the client app.softwareVersion
name
- the name of the client software using stanza.ioversion
- the version of the client software using stanza.ioos
- the operating system that the client is running on
timeout
- number of seconds that IQ requests will wait for a response before generating a timeout error.lang
- preferred language used by the client, such as'en'
or'de'
.
Request to join a Multi-User Chat room.
room
- The bare JID of the room to joinnick
- The requested nickname to use in the room. Note: You are not guaranteed to be assigned this nick.options
- Additional presence information to attach to the join request, in particular:joinMuc
- A dictionary of options for how to join the room:password
- Optional password for entering the roomhistory
- May betrue
to receive the room's default history replay, or may specifymaxstanzas
,seconds
, orsince
to specify a history replay range in terms of number of messages, a given time range, or since a particular time.
client.joinRoom('[email protected]', 'User', {
status: 'This will be my status in the MUC',
joinMuc: {
password: 'hunter2',
history: {
maxstanzas: 20
}
}
});
Creates a new JID
(Jabber IDentifier) object, which represents an address in the XMPP network.
jid
- a string of the form[username@]domain[/resource]
(or an existingJID
object)
var someServer = new JID('somedomain.example.com');
var friendAddress = new JID('[email protected]');
var addressOfParticularConnection = new JID('[email protected]/laptopclient');
All JID
objects expose the following properties:
local
- If theJID
is of the form'[email protected]'
, then thelocal
value would be the'user'
portiondomain
- If theJID
is of the form'[email protected]'
(or'example.com'
), then thedomain
value would be'example.com'
resource
- If theJID
is of the form'[email protected]/res'
(or even'example.com/res'
), then theresource
value would be'res'
bare
- The bareJID
contains only the local and domain sections, eg'[email protected]'
full
- The fullJID
contains the local, domain, and resource sections, eg'[email protected]/res'
Example:
{
type: 'chat',
to: JID,
from: JID,
body: 'this is a chat'
}
Example:
{
type: 'chat',
to: JID,
from: JID,
chatState: 'composing'
}
Example:
{
to: JID,
from: JID,
caps: {
hash: 'sha-1',
node: 'https://stanza.io',
ver: 'rs/tl9NCfXBpKoOYUy+JdBbPGDg='
}
}
Example:
{
type: 'subscribe',
to: JID,
from: JID
}
Example:
{
type: 'unsubscribed',
to: JID,
from: JID
}