Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.

Commit cafff7a

Browse files
committed
update node-xmpp-client to 3.0
1 parent 02fa6ff commit cafff7a

File tree

4 files changed

+49
-52
lines changed

4 files changed

+49
-52
lines changed

lib/simple-xmpp.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
var xmpp = require('node-xmpp-client');
28+
var Stanza = xmpp.Stanza;
2829
var EventEmitter = require('events').EventEmitter;
2930
var util = require('util');
3031
var qbox = require('qbox');
@@ -46,7 +47,6 @@ function SimpleXMPP() {
4647
//setting status here
4748
this.STATUS = STATUS;
4849
var self = this;
49-
this.Element = xmpp.Element;
5050
var config;
5151
var conn;
5252
var probeBuddies = {};
@@ -83,7 +83,7 @@ function SimpleXMPP() {
8383
if(!joinedRooms[room]){
8484
joinedRooms[room] = true;
8585
}
86-
var stanza = new xmpp.Stanza.Element('presence', { to: to }).
86+
var stanza = new Stanza('presence', { to: to }).
8787
c('x', { xmlns: 'http://jabber.org/protocol/muc' });
8888
// XEP-0045 7.2.6 Password-Protected Rooms
8989
if (password != null && password != "")
@@ -95,7 +95,7 @@ function SimpleXMPP() {
9595
this.invite = function(to, room, reason) {
9696

9797
$.ready(function() {
98-
var stanza = new xmpp.Stanza.Element('message', { to: room }).
98+
var stanza = new Stanza('message', { to: room }).
9999
c('x', { xmlns: 'http://jabber.org/protocol/muc#user' }).
100100
c('invite', {to: to});
101101
if (reason)
@@ -108,15 +108,15 @@ function SimpleXMPP() {
108108
this.subscribe = function(to) {
109109

110110
$.ready(function() {
111-
var stanza = new xmpp.Stanza('presence', { to: to, type: 'subscribe' });
111+
var stanza = new Stanza('presence', { to: to, type: 'subscribe' });
112112
conn.send(stanza);
113113
});
114114
};
115115

116116
this.unsubscribe = function(to) {
117117

118118
$.ready(function() {
119-
var stanza = new xmpp.Stanza('presence', { to: to, type: 'unsubscribe' });
119+
var stanza = new Stanza('presence', { to: to, type: 'unsubscribe' });
120120
conn.send(stanza);
121121
});
122122
};
@@ -126,23 +126,23 @@ function SimpleXMPP() {
126126
// Send a 'subscribed' notification back to accept the incoming
127127
// subscription request
128128
$.ready(function() {
129-
var stanza = new xmpp.Stanza('presence', { to: to, type: 'subscribed' });
129+
var stanza = new Stanza('presence', { to: to, type: 'subscribed' });
130130
conn.send(stanza);
131131
});
132132
};
133133

134134
this.acceptUnsubscription = function(to) {
135135

136136
$.ready(function() {
137-
var stanza = new xmpp.Stanza('presence', { to: to, type: 'unsubscribed' });
137+
var stanza = new Stanza('presence', { to: to, type: 'unsubscribed' });
138138
conn.send(stanza);
139139
});
140140
};
141141

142142
this.getRoster = function() {
143143

144144
$.ready(function() {
145-
var roster = new xmpp.Stanza('iq', { id: 'roster_0', type: 'get' });
145+
var roster = new Stanza('iq', { id: 'roster_0', type: 'get' });
146146
roster.c('query', { xmlns: 'jabber:iq:roster' });
147147
conn.send(roster);
148148
});
@@ -152,7 +152,7 @@ function SimpleXMPP() {
152152

153153
probeBuddies[buddy] = true;
154154
$.ready(function() {
155-
var stanza = new xmpp.Stanza('presence', {type: 'probe', to: buddy});
155+
var stanza = new Stanza('presence', {type: 'probe', to: buddy});
156156
events.once('probe_' + buddy, callback);
157157
conn.send(stanza);
158158
});
@@ -177,7 +177,7 @@ function SimpleXMPP() {
177177
this.getVCard = function(buddy, callback) {
178178
$.ready(function() {
179179
var id = 'get-vcard-' + buddy.split('@').join('--');
180-
var stanza = new xmpp.Stanza('iq', { type: 'get', id: id }).
180+
var stanza = new Stanza('iq', { type: 'get', id: id }).
181181
c('vCard', { xmlns: 'vcard-temp' }).
182182
up();
183183
iqCallbacks[id] = function(response) {
@@ -195,7 +195,7 @@ function SimpleXMPP() {
195195
this.getVCardForUser = function(jid, user, callback) {
196196
$.ready(function() {
197197
var id = 'get-vcard-' + user.split('@').join('-');
198-
var stanza = new xmpp.Stanza('iq', { from: jid, type: 'get', id: id, to: user }).
198+
var stanza = new Stanza('iq', { from: jid, type: 'get', id: id, to: user }).
199199
c('vCard', { xmlns: 'vcard-temp' }).
200200
up();
201201
iqCallbacks[id] = function(response) {
@@ -228,7 +228,7 @@ function SimpleXMPP() {
228228
// * add caps support
229229
this.setPresence = function(show, status) {
230230
$.ready(function() {
231-
var stanza = new xmpp.Stanza('presence');
231+
var stanza = new Stanza('presence');
232232
if(show && show !== STATUS.ONLINE) {
233233
stanza.c('show').t(show);
234234
}
@@ -251,7 +251,7 @@ function SimpleXMPP() {
251251
// See XEP-0085 for details on the meaning of those states.
252252
this.setChatstate = function(to, state) {
253253
$.ready(function() {
254-
var stanza = new xmpp.Stanza('message', { to: to }).
254+
var stanza = new Stanza('message', { to: to }).
255255
c(state, { xmlns: NS_CHATSTATES }).
256256
up();
257257
conn.send(stanza);
@@ -267,7 +267,7 @@ function SimpleXMPP() {
267267

268268
this.disconnect = function() {
269269
$.ready(function() {
270-
var stanza = new xmpp.Stanza('presence', { type: 'unavailable' });
270+
var stanza = new Stanza('presence', { type: 'unavailable' });
271271
stanza.c('status').t('Logged out');
272272
conn.send(stanza);
273273
});
@@ -297,7 +297,7 @@ function SimpleXMPP() {
297297

298298
conn.on('online', function(data){
299299
if(! config.skipPresence) {
300-
conn.send(new xmpp.Stanza('presence'));
300+
conn.send(new Stanza('presence'));
301301
}
302302
events.emit('online', data);
303303
$.start();
@@ -406,7 +406,7 @@ function SimpleXMPP() {
406406
}
407407
capBuddies[fullNode].push(id);
408408

409-
var getCaps = new xmpp.Stanza('iq', { id: 'disco1', to: from, type: 'get' });
409+
var getCaps = new Stanza('iq', { id: 'disco1', to: from, type: 'get' });
410410
getCaps.c('query', { xmlns: 'http://jabber.org/protocol/disco#info', node: fullNode });
411411
conn.send(getCaps);
412412
}
@@ -417,7 +417,7 @@ function SimpleXMPP() {
417417
}
418418
} else if (stanza.is('iq')) {
419419
if (stanza.getChild('ping', 'urn:xmpp:ping')) {
420-
conn.send(new xmpp.Stanza('iq', { id: stanza.attrs.id, to: stanza.attrs.from, type: 'result' }));
420+
conn.send(new Stanza('iq', { id: stanza.attrs.id, to: stanza.attrs.from, type: 'result' }));
421421
}
422422
// Response to capabilities request?
423423
else if (stanza.attrs.id === 'disco1') {
@@ -464,5 +464,7 @@ function SimpleXMPP() {
464464

465465
}
466466

467+
SimpleXMPP.prototype.Element = xmpp.Element
468+
467469
// Allow for multiple connections
468470
module.exports.SimpleXMPP = SimpleXMPP;

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
],
2828

2929
"dependencies": {
30-
"node-xmpp-client": "^1.0.0",
30+
"node-xmpp-client": "^3.0.0",
3131
"qbox": "0.1.x"
3232
},
3333

3434
"devDependencies": {
35-
"ltx": ">= 0.0.5",
3635
"nodemock": ">= 0.2.13",
3736
"horaa": ">= 0.1.1alpha"
3837
},

readme.md

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ Node Simple XMPP
22
================
33
Simple High Level NodeJS XMPP Library
44

5-
Dependencies
6-
------------
7-
sudo apt-get install libexpat1 libexpat1-dev libicu-dev
8-
95
Install
106
-------
117
npm install simple-xmpp
@@ -78,7 +74,7 @@ xmpp.on('chat', function(from, message) {
7874
console.log('%s says %s', from, message);
7975
});
8076
```
81-
77+
8278
#### Chat State
8379
event emitted when a buddys chatstate changes [ 'active', 'composing', 'paused', 'inactive', 'gone' ]
8480

@@ -108,9 +104,9 @@ Event emitted when state of the buddy on your chat list changes
108104
DND - Buddy set its status as "Do Not Disturb" or "Busy",
109105
ONLINE - Buddy comes online or available to chat
110106
OFFLINE - Buddy goes offline
111-
@param statusText - status message of the buddy (known as "custom message" in Gmail).
107+
@param statusText - status message of the buddy (known as "custom message" in Gmail).
112108
`null` if the buddy has not specified any status text.
113-
109+
114110
@param resource is the last parameter of JID, which tells that the user is logged in via with device. (e.g mobile , Desktop )
115111
*/
116112
xmpp.on('buddy', function(jid, state, statusText,resource) {
@@ -127,7 +123,7 @@ xmpp.on('groupbuddy', function(conference, from, state, statusText) {
127123
```
128124
#### Buddy capabilities
129125
Event emitted when a buddy's client capabilities are retrieved. Capabilities specify which additional
130-
features supported by the buddy's XMPP client (such as audio and video chat). See
126+
features supported by the buddy's XMPP client (such as audio and video chat). See
131127
[XEP-0115: Entity Capabilities](http://xmpp.org/extensions/xep-0115.html) for more information.
132128

133129
```javascript
@@ -209,7 +205,7 @@ Set presence
209205
*/
210206
xmpp.setPresence('away', 'Out to lunch');
211207
```
212-
208+
213209
Set chatstate
214210

215211
```javascript
@@ -224,7 +220,7 @@ Get vCard
224220

225221
```javascript
226222
/*
227-
@param buddy - The JID to use
223+
@param buddy - The JID to use
228224
@param callback - The function to call when the vCard is retreived. The returned data will be a JSON object
229225
*/
230226
xmpp.getVCard('[email protected]', function (vcard) {

0 commit comments

Comments
 (0)