Node Simple XMPP
Simple High Level NodeJS XMPP Library
Dependencies
sudo apt-get install libexpat1 libexpat1-dev libicu-dev
Install
npm install simple-xmpp2
Example
var xmpp = ; xmpp; xmpp; xmpp; xmpp; xmpp; xmpp;// check for incoming subscription requestsxmpp;
Documentation
Events
Online
Event emitted when successfully connected. Callback is passed an object containing information about the newly connected user.
xmpp;
Close
event where the connection has been closed
xmpp;
Chat
Event emitted when somebody sends a chat message to you
xmpp;
Chat State
event emitted when a buddys chatstate changes [ 'active', 'composing', 'paused', 'inactive', 'gone' ]
xmpp;
Group Chat
event where emits when somebody sends a group chat message to you
xmpp;
Buddy
Event emitted when state of the buddy on your chat list changes
/** @param jid - is the id of buddy (eg:- hello@gmail.com) @param state - state of the buddy. value will be one of the following constant can be access via require('simple-xmpp').STATUS AWAY - Buddy goes away DND - Buddy set its status as "Do Not Disturb" or "Busy", ONLINE - Buddy comes online or available to chat OFFLINE - Buddy goes offline @param statusText - status message of the buddy (known as "custom message" in Gmail). `null` if the buddy has not specified any status text. @param resource is the last parameter of JID, which tells that the user is logged in via with device. (e.g mobile , Desktop )*/xmpp;
Group Buddy
Event emitted when state of the buddy on group chat you recently joined changes
xmpp;
Buddy capabilities
Event emitted when a buddy's client capabilities are retrieved. Capabilities specify which additional features supported by the buddy's XMPP client (such as audio and video chat). See XEP-0115: Entity Capabilities for more information.
xmpp;
Stanza
access core stanza element when such received Fires for every incoming stanza
/** @param stanza - the core object xmpp.on('stanza', function(stanza) { console.log(stanza); });*/
Methods
Send Chat Messages
/** @param to - Address to send (eg:- abc@gmail.com - room@conference.domain.tld) @param message - message to be sent @param group - if true, send the message in a group chat*/ xmpp;
Send Friend requests
/** @param to - Address to send (eg:- your.friend@gmail.com)*/xmpp;
Accept Friend requests
/** @param from - Address to accept (eg:- your.friend@gmail.com)*/xmpp;
Unsubscribe Friend
/** @param to - Address to unsubscribe (eg:- no.longer.friend@gmail.com)*/xmpp;
Accept unsubscription requests
/** @param from - Address to accept (eg:- no.longer.friend@gmail.com)*/xmpp;
Set presence
/** @param show - Your current presence state ['away', 'dnd', 'xa', 'chat'] @param status - (optional) free text as your status message*/xmpp;
Set chatstate
/** @param to - The target JID (ie. person you are chatting with) to receive the chatstate @param state - Your current chatstate [ 'active', 'composing', 'paused', 'inactive', 'gone' ]*/xmpp;
Get vCard
/* @param buddy - The JID to use @param callback - The function to call when the vCard is retreived. The returned data will be a JSON object*/xmpp;
Probe the state of the buddy
/** @param jid - Buddy's id (eg:- abc@gmail.com) @param state - State of the buddy. value will be one of the following constant can be access via require('simple-xmpp').STATUS AWAY - Buddy goes away DND - Buddy set its status as "Do Not Disturb" or "Busy", ONLINE - Buddy comes online or available to chat OFFLINE - Buddy goes offline*/ xmpp;
Disconnect session
/** no params*/ xmpp;
Fields
Fields provided Additional Core functionalies
xmpp.conn
The underlying connection object
var xmpp = simpleXMPP;xmppconn; // the connection object
xmpp.Element
XMPP Element class (from node-xmpp)
var xmpp = simpleXMPP;xmppElement; // the connection object