[Pkg-javascript-commits] [ltx] 103/469: router acceptConnection(): hook inStream 'close' event
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 1b901e0a9f9b8103d15bfc987c7b66f7906d79ab
Author: Astro <astro at spaceboyz.net>
Date: Tue Sep 7 00:19:40 2010 +0200
router acceptConnection(): hook inStream 'close' event
---
lib/xmpp/router.js | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/xmpp/router.js b/lib/xmpp/router.js
index 6263e97..f2bb979 100644
--- a/lib/xmpp/router.js
+++ b/lib/xmpp/router.js
@@ -286,9 +286,8 @@ Router.prototype.acceptConnection = function(inStream) {
var outStream = ctx.sendRaw(Server.dialbackVerify(to, from, inStream.streamId, key),
from);
- // TODO: hook inStream close
// these are needed before for removeListener()
- var onVerified, onClose;
+ var onVerified, onClose, onCloseIn, rmCbs;
onVerified = function(from, to, id, isValid) {
from = nameprep.prepare(from);
to = nameprep.prepare(to);
@@ -307,16 +306,29 @@ Router.prototype.acceptConnection = function(inStream) {
inStream.end();
}
- outStream.removeListener('dialbackVerified', onVerified);
- outStream.removeListener('close', onClose);
+ rmCbs();
};
onClose = function() {
// outgoing connection didn't work out, tell the incoming
// connection
inStream.send(Server.dialbackResult(to, from, false));
+
+ rmCbs();
+ };
+ onCloseIn = function() {
+ // t'was the incoming stream that wanted to get
+ // verified, nothing to do remains
+
+ rmCbs();
+ };
+ rmCbs = function() {
+ outStream.removeListener('dialbackVerified', onVerified);
+ outStream.removeListener('close', onClose);
+ inStream.removeListener('close', onCloseIn);
};
outStream.addListener('dialbackVerified', onVerified);
outStream.addListener('close', onClose);
+ inStream.addListener('close', onCloseIn);
} else {
inStream.error('host-unknown', to + ' is not served here');
}
--
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