[Pkg-javascript-commits] [ltx] 80/469: router: purge queue on outStream close event

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:01:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit db8dfb58c45551b7a021563a8f3fee14cd793c77
Author: Astro <astro at spaceboyz.net>
Date:   Mon Sep 6 00:05:41 2010 +0200

    router: purge queue on outStream close event
---
 lib/xmpp/router.js | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/lib/xmpp/router.js b/lib/xmpp/router.js
index b1ad459..2b044f7 100644
--- a/lib/xmpp/router.js
+++ b/lib/xmpp/router.js
@@ -88,7 +88,24 @@ DomainContext.prototype.getOutStream = function(domain) {
 	this.setupStream(domain, outStream);
 
 	outStream.addListener('close', function() {
-	    // TODO: purge queue
+	    // purge queue
+	    if (outStream.queue) {
+		outStream.queue.forEach(function(stanza) {
+					    // do not provoke ping-pong effects
+					    if (stanza.attrs.type === 'error')
+						return;
+
+					    var dest = stanza.attrs.to;
+					    stanza.attrs.to = stanza.attrs.from;
+					    stanza.attrs.from = dest;
+					    stanza.attrs.type = 'error';
+					    // TODO: add <error/> child if any programs wants to use that
+					    self.receive(stanza);
+					});
+	    }
+	    delete outStream.queue;
+
+	    // remove from DomainContext
 	    delete self.s2sOut[domain];
 	});
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list