From 623d3169e6fa65f307dbfc41880ff3d47ee04052 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sat, 20 Jun 2015 22:34:48 -0700 Subject: [PATCH 01/16] Updated to support Node 0.12.x --- lib/superfeedr.js | 16 +++++++++------- package.json | 10 ++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/superfeedr.js b/lib/superfeedr.js index f8dbb66..b92c480 100644 --- a/lib/superfeedr.js +++ b/lib/superfeedr.js @@ -1,4 +1,6 @@ -var xmpp = require('node-xmpp'); +var Client = require('node-xmpp-client'); +var Core = require('node-xmpp-core'); +var ltx = require('ltx'); var util = require('util'); var EventEmitter = require('events').EventEmitter; @@ -11,11 +13,11 @@ function Superfeedr(login, password, resource) { } this.callbacks = {}; - this.client = new xmpp.Client({ jid: this.jid, password: password }); + this.client = new Client({ jid: this.jid, password: password }); var self = this; this.client.on('online', function() { - self.client.send(new xmpp.Element('presence', { }).c('show').t('chat').up().c('status').t('')); + self.client.send(new ltx.Element('presence', { }).c('show').t('chat').up().c('status').t('')); self.emit('connected'); }); @@ -187,7 +189,7 @@ util.inherits(Superfeedr, EventEmitter); Superfeedr.prototype.subscribe = function(url, clb) { var id = Math.floor(Math.random()*100000).toString(); - var subscribeStanza = new xmpp.Iq({to: SUPERFEEDR_ENDPOINT, id:id, type:'set', from: this.client.jid}) + var subscribeStanza = new Core.Stanza.Iq({to: SUPERFEEDR_ENDPOINT, id:id, type:'set', from: this.client.jid}) .c("pubsub", {xmlns: "http://jabber.org/protocol/pubsub"}) .c("subscribe", {node: url, jid: this.jid}).root(); @@ -221,7 +223,7 @@ Superfeedr.prototype.subscribe = function(url, clb) { Superfeedr.prototype.unsubscribe = function(url, clb) { var id = Math.floor(Math.random()*100000).toString(); - var unsubscribeStanza = new xmpp.Iq({to: SUPERFEEDR_ENDPOINT, id:id, type:'set', from: this.client.jid}) + var unsubscribeStanza = new Core.Stanza.Iq({to: SUPERFEEDR_ENDPOINT, id:id, type:'set', from: this.client.jid}) .c("pubsub", {xmlns: "http://jabber.org/protocol/pubsub"}) .c("unsubscribe", {node: url, jid: this.jid}).root(); this.callbacks[id] = function(response, superfeedr) { @@ -260,7 +262,7 @@ Superfeedr.prototype.list = function(page, clb) { page = 1; } - var listStanza = new xmpp.Iq({type:'get', from: this.client.jid, to: SUPERFEEDR_ENDPOINT, id:id}) + var listStanza = new Core.Stanza.Iq({type:'get', from: this.client.jid, to: SUPERFEEDR_ENDPOINT, id:id}) .c("pubsub", {xmlns: "http://jabber.org/protocol/pubsub", "xmlns:superfeedr":"http://superfeedr.com/xmpp-pubsub-ext"}) .c("subscriptions", {jid: this.jid, "superfeedr:page": page}).root(); @@ -300,7 +302,7 @@ Superfeedr.prototype.list = function(page, clb) { Superfeedr.prototype.retrieve = function retrieve(url, clb) { var self = this; var id = Math.floor(Math.random()*100000).toString(); - var retrieveStanza = new xmpp.Iq({to: SUPERFEEDR_ENDPOINT, id:id, type:'get', from: self.client.jid}) + var retrieveStanza = new Core.Stanza.Iq({to: SUPERFEEDR_ENDPOINT, id:id, type:'get', from: self.client.jid}) .c("pubsub", {xmlns: "http://jabber.org/protocol/pubsub"}) .c("items", {node: url}).root(); diff --git a/package.json b/package.json index 890ed18..ab547ba 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,14 @@ "node": ">=0.6.0" }, "dependencies": { - "node-xmpp": ">=0.3.1" + "ltx": "^0.9.0", + "node-xmpp-client": "^1.0.0-alpha20", + "node-xmpp-core": "^1.0.0-alpha14" }, "devDependencies": { - "mocha": "0.1.0", - "request": "*", - "underscore": "*" + "mocha": "0.1.0", + "request": "*", + "underscore": "*" }, "scripts": { "test": "export NODE_ENV=test; mocha " From 881fc1eadaeb2e933dee72d9cd8f4108b40153c7 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sun, 21 Jun 2015 16:28:29 -0700 Subject: [PATCH 02/16] add an error event handler to the client --- lib/superfeedr.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/superfeedr.js b/lib/superfeedr.js index b92c480..0ac0764 100644 --- a/lib/superfeedr.js +++ b/lib/superfeedr.js @@ -21,6 +21,10 @@ function Superfeedr(login, password, resource) { self.emit('connected'); }); + this.client.on('error', function(err) { + self.emit('error', err); + }); + this.client.on('stanza', function(stanza) { if(self.callbacks[stanza.attrs.id]) { self.callbacks[stanza.attrs.id](stanza, self); From 65d4137f77563916f060381adfbdd519ab5bbb36 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sun, 21 Jun 2015 16:29:46 -0700 Subject: [PATCH 03/16] update mocha to latest version, handle client error in tests --- package.json | 2 +- test/test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ab547ba..089246d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "node-xmpp-core": "^1.0.0-alpha14" }, "devDependencies": { - "mocha": "0.1.0", + "mocha": "^2.2.5", "request": "*", "underscore": "*" }, diff --git a/test/test.js b/test/test.js index 39ffa7e..ed9ae17 100644 --- a/test/test.js +++ b/test/test.js @@ -9,6 +9,9 @@ describe('superfeedr', function () { before(function (done) { client = new Superfeedr("nodesample", "nodesample"); client.on('connected', done); + client.on('error', function(err) { + done(new Error(err)); + }); }); describe('List', function () { From ee44638cc048bf5c5a7c733cd462a2f29e23610e Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sun, 21 Jun 2015 23:48:18 -0700 Subject: [PATCH 04/16] Update Superfeedr account used in tests --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index ed9ae17..b4d91ba 100644 --- a/test/test.js +++ b/test/test.js @@ -7,7 +7,7 @@ describe('superfeedr', function () { var client = null; before(function (done) { - client = new Superfeedr("nodesample", "nodesample"); + client = new Superfeedr("nodesuperfeedrTest", "nodesuperfeedrTest123"); client.on('connected', done); client.on('error', function(err) { done(new Error(err)); From 3b03f612029c30d9104c1d5aeab67cc0ca4297be Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Thu, 2 Jul 2015 12:54:57 -0700 Subject: [PATCH 05/16] Add additional event handlers --- lib/superfeedr.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/superfeedr.js b/lib/superfeedr.js index 0ac0764..711d0c6 100644 --- a/lib/superfeedr.js +++ b/lib/superfeedr.js @@ -25,6 +25,18 @@ function Superfeedr(login, password, resource) { self.emit('error', err); }); + this.client.on('offline', function() { + self.emit('offline'); + }); + + this.client.on('reconnect', function() { + self.emit('reconnected'); + }); + + this.client.on('disconnect', function() { + self.emit('disconnected'); + }); + this.client.on('stanza', function(stanza) { if(self.callbacks[stanza.attrs.id]) { self.callbacks[stanza.attrs.id](stanza, self); From eeedc1adbd9efc1c704c3de9de5c9e18c9cb9432 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Thu, 6 Aug 2015 23:28:07 -0700 Subject: [PATCH 06/16] Add keepalive settings --- lib/superfeedr.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/superfeedr.js b/lib/superfeedr.js index 711d0c6..6e87117 100644 --- a/lib/superfeedr.js +++ b/lib/superfeedr.js @@ -7,14 +7,20 @@ var EventEmitter = require('events').EventEmitter; SUPERFEEDR_ENDPOINT = "firehoser.superfeedr.com"; function Superfeedr(login, password, resource) { + + var self = this; + this.jid = login + "@superfeedr.com"; + if(resource !== undefined) { this.jid += '/'+resource } this.callbacks = {}; this.client = new Client({ jid: this.jid, password: password }); - var self = this; + + this.client.connection.socket.setTimeout(0); + this.client.connection.socket.setKeepAlive(true, 10000); this.client.on('online', function() { self.client.send(new ltx.Element('presence', { }).c('show').t('chat').up().c('status').t('')); From 5a0f140f84e1dcb2c6fefabcbffb249872c5fbf6 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sun, 30 Aug 2015 15:49:19 -0700 Subject: [PATCH 07/16] Add Travis CI config file --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5c9268c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.12.4" From 9601252ab22266e61169dd35c68bb6711bae7e22 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sun, 30 Aug 2015 15:54:32 -0700 Subject: [PATCH 08/16] Add Travis CI badge to README --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index 46f27ab..af5bb73 100644 --- a/README.markdown +++ b/README.markdown @@ -1,3 +1,5 @@ + + Superfeedr-node =============== From 2867e55d89626f68a7569eda853dfcd9849e6763 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sun, 30 Aug 2015 15:56:35 -0700 Subject: [PATCH 09/16] Add Node v0.12.7 to Travis CI config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5c9268c..a29664f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: node_js node_js: - "0.12.4" + - "0.12.7" From 45d202e7caafb582ad2c1535383757a2ed972b8a Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sun, 30 Aug 2015 16:06:08 -0700 Subject: [PATCH 10/16] Update README --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index af5bb73..5161726 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ - + Superfeedr-node =============== From 2e815b4219e621b55149412ddd8727ad8aebe154 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Thu, 24 Sep 2015 18:49:39 -0700 Subject: [PATCH 11/16] Update Travis CI settings --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a29664f..b0206a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,4 @@ language: node_js node_js: - "0.12.4" - "0.12.7" + - "4.1.x" From 21190f28db644c66e6e5c97cf49941177572b2ea Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Thu, 24 Sep 2015 18:56:54 -0700 Subject: [PATCH 12/16] Update Travis CI settings --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b0206a7..3f7161c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,6 @@ language: node_js node_js: - "0.12.4" - "0.12.7" - - "4.1.x" + - "4.0.0" + - "4.1.0" + - "4.1.1" From 3921ffc50e1e1716949f4001403128c6717d24fc Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Fri, 6 Nov 2015 12:20:11 -0800 Subject: [PATCH 13/16] Updated package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 089246d..435aaab 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ }, "dependencies": { "ltx": "^0.9.0", - "node-xmpp-client": "^1.0.0-alpha20", - "node-xmpp-core": "^1.0.0-alpha14" + "node-xmpp-client": "^2.1.0", + "node-xmpp-core": "^4.2.0" }, "devDependencies": { "mocha": "^2.2.5", From ce5dc037336d58566c21df14371516abf9b8b09a Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Sat, 7 Nov 2015 23:00:47 -0800 Subject: [PATCH 14/16] Update tests --- .travis.yml | 3 +++ test/test.js | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f7161c..5d509b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,6 @@ node_js: - "4.0.0" - "4.1.0" - "4.1.1" + - "4.2.1" + - "4.2.2" + - "5.0.0" diff --git a/test/test.js b/test/test.js index b4d91ba..c5beb1a 100644 --- a/test/test.js +++ b/test/test.js @@ -48,7 +48,7 @@ describe('superfeedr', function () { describe('retrieve', function() { before(function(done) { client.subscribe("http://blog.superfeedr.com/atom.xml", function(err, feed) { - if(!err && feed.url === "http://blog.superfeedr.com/atom.xml" && feed.title === 'Superfeedr Blog : Real-time cloudy thoughts from a super-hero') { + if(!err && feed.url === "http://blog.superfeedr.com/atom.xml" && feed.title === 'Superfeedr Blog') { done(); } }); @@ -92,7 +92,7 @@ describe('superfeedr', function () { it('should call the subscription callback', function (done) { client.subscribe("http://blog.superfeedr.com/atom.xml", function (err, feed) { - if (!err && feed.url === "http://blog.superfeedr.com/atom.xml" && feed.title === 'Superfeedr Blog : Real-time cloudy thoughts from a super-hero') { + if (!err && feed.url === "http://blog.superfeedr.com/atom.xml" && feed.title === 'Superfeedr Blog') { done(); } }); From 8d779bd208e13d8691105759ddbfe2a073b3585e Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Wed, 11 Nov 2015 16:26:32 -0800 Subject: [PATCH 15/16] Update .travis.yml --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5d509b0..c205ec3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,14 @@ language: node_js +sudo: false +env: + - CXX=g++-4.8 +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 + node_js: - "0.12.4" - "0.12.7" From 1c8fb424d19bf3da14d2c041389c28395b88f713 Mon Sep 17 00:00:00 2001 From: Dave Penfold Date: Fri, 18 Dec 2015 21:04:26 -0800 Subject: [PATCH 16/16] Update .travis.yml --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index c205ec3..fe04cea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,8 @@ node_js: - "4.1.1" - "4.2.1" - "4.2.2" + - "4.2.3" - "5.0.0" + - "5.1.1" + - "5.2.0" + - "5.3.0"