[Pkg-javascript-commits] [ltx] 126/469: component & server: use SRV connecter events properly

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:01:13 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 32239b1fabd8a586a40a39d78cba7ca13ec0e5ad
Author: Astro <astro at spaceboyz.net>
Date:   Thu Sep 9 18:52:10 2010 +0200

    component & server: use SRV connecter events properly
---
 lib/xmpp/component.js | 14 +++++++++-----
 lib/xmpp/server.js    | 16 ++++++++++------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/lib/xmpp/component.js b/lib/xmpp/component.js
index 771b596..5dd20ba 100644
--- a/lib/xmpp/component.js
+++ b/lib/xmpp/component.js
@@ -25,17 +25,21 @@ function Component(params) {
     this.password = params.password;
     this.xmlns = NS_COMPONENT;
     this.streamTo = this.jid.domain;
-    // Immediately start stream
-    this.socket.addListener('connect', function() {
-	self.startStream();
-    });
+
     this.addListener('streamStart', function(streamAttrs) {
 	self.onStreamStart(streamAttrs);
     });
     this.addListener('rawStanza', function(stanza) {
 	self.onRawStanza(stanza);
     });
-    SRV.connect(this.socket, [], params.host, params.port);
+    var attempt = SRV.connect(this.socket, [], params.host, params.port);
+    attempt.addListener('connect', function() {
+	self.startParser();
+	self.startStream();
+    });
+    attempt.addListener('error', function(e) {
+	self.emit('error', e);
+    });
 }
 
 sys.inherits(Component, Connection.Connection);
diff --git a/lib/xmpp/server.js b/lib/xmpp/server.js
index 68ba2e1..61310fe 100644
--- a/lib/xmpp/server.js
+++ b/lib/xmpp/server.js
@@ -157,9 +157,6 @@ console.log({outCreds:self.credentials});
     if (!this.credentials)
 	delete this.xmppVersion;
 
-    this.socket.addListener('connect', function() {
-	self.startStream();
-    });
     this.socket.addListener('secure', function() {
 	self.startStream();
     });
@@ -185,9 +182,16 @@ console.log({outCreds:self.credentials});
 	}
     });
 
-    SRV.connect(this.socket, ['_xmpp-server._tcp',
-			      '_jabber._tcp'],
-		destDomain, 5269);
+    var attempt = SRV.connect(this.socket, ['_xmpp-server._tcp',
+					    '_jabber._tcp'],
+			      destDomain, 5269);
+    attempt.addListener('connect', function() {
+	self.startParser();
+	self.startStream();
+    });
+    attempt.addListener('error', function(e) {
+	self.emit('error', e);
+    });
 };
 sys.inherits(exports.OutgoingServer, Server);
 

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