-
new Client(options)createClient(options)ClientMethodsclient.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.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.publishAvatar(id, data, [cb])client.publishGeoLoc(data, [cb])client.publishMood(mood, text, [cb])client.publishNick(nick, [cb])client.publishReachability(data, [cb])client.publishVCard(vcard, [cb])client.sendLog(jid, opts)client.setPrivateData(opts, [cb])client.updateAccount(jid, data, [cb])client.useAvatars(data, [cb])
-
attentionauth:failedauth:successavailableavatarblockbosh:terminatecarbon:receivedcarbon:sentchat:statechatconnectedcredentials:updatedataformdisco:capsdisconnectedgeolocgroupchatid:IDiq:get:NAMEiq:set:NAMEjingle:acceptedjingle:holdjingle:incomingjingle:localstream:addedjingle:localstream:removedjingle:mutejingle:outgoingjingle:remotestream:addedjingle:remotestream:removedjingle:resumedjingle:ringingjingle:terminatedjingle:unmutemessage:errormessage:sentmessagemuc:availablemuc:declinedmuc:destroyedmuc:errormuc:invitemuc:joinmuc:leavemuc:subjectmuc:unavailablenickpresence:errorpresencepubsub:eventraw:incomingraw:outgoingreachabilityreceipt[:ID]replace[:ID]roster:updateroster:versasl:abortsasl:challengesasl:failuresasl:successsession:boundsession:endsession:errorsession:startedstanzastream:datastream:endstream:errorstream:management:enabledstream:management:failedstream:management:resumedsubscribesubscribedunavailableunblockunsubscribeunsubscribed
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: 'test@example.com',
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: 'test@example.com',
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.passwordserver- specify the hostname of the server to initially connect to, if different fromjid.domain.resource- suggest a specific resource for this session.credentialsusername- 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 totrueto 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.softwareVersionname- 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'.
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 existingJIDobject)
var someServer = new JID('somedomain.example.com');
var friendAddress = new JID('friend@example.com');
var addressOfParticularConnection = new JID('me@example.com/laptopclient');All JID objects expose the following properties:
local- If theJIDis of the form'user@example.com', then thelocalvalue would be the'user'portiondomain- If theJIDis of the form'user@example.com'(or'example.com'), then thedomainvalue would be'example.com'resource- If theJIDis of the form'user@example.com/res'(or even'example.com/res'), then theresourcevalue would be'res'bare- The bareJIDcontains only the local and domain sections, eg'user@example.com'full- The fullJIDcontains the local, domain, and resource sections, eg'user@example.com/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
}