[Pkg-javascript-commits] [ltx] 104/469: router: unregister(domain)

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:01:09 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 56fa6dbddd740fdd09202046ce550ab40201a1d5
Author: Astro <astro at spaceboyz.net>
Date:   Tue Sep 7 01:12:50 2010 +0200

    router: unregister(domain)
---
 lib/xmpp/router.js | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/xmpp/router.js b/lib/xmpp/router.js
index f2bb979..8fd3d1c 100644
--- a/lib/xmpp/router.js
+++ b/lib/xmpp/router.js
@@ -227,6 +227,16 @@ DomainContext.prototype.receive = function(stanza) {
 	this.stanzaListener(stanza);
 };
 
+DomainContext.prototype.end = function() {
+    var shutdown = function(conns) {
+	for(var domain in conns)
+	    if (conns.hasOwnProperty(domain))
+		conns[domain].end();
+    };
+    shutdown(this.s2sOut);
+    shutdown(this.s2sIn);
+};
+
 /**
  * TODO:
  * * SASL EXTERNAL
@@ -354,7 +364,17 @@ Router.prototype.register = function(domain, listener) {
     this.getContext(domain).stanzaListener = listener;
 };
 
-// TODO: unregister w/ connections teardown
+/**
+ * Unregister a context and stop its connections
+ */
+Router.prototype.unregister = function(domain) {
+    if (this.hasContext(domain)) {
+	this.ctxs[domain].end();
+
+console.log('deleting '+domain);
+	delete this.ctxs[domain];
+    }
+};
 
 Router.prototype.send = function(stanza) {
     if (stanza.root)

-- 
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