Cleaning up and documenting some changes.

Wed, 24 Feb 2010 22:04:06 -0800

author
zuwiki <zuwiki@gmail.com>
date
Wed, 24 Feb 2010 22:04:06 -0800
changeset 15
b328899c936a
parent 14
aaad945d10ba
child 16
74a24eb1fb44

Cleaning up and documenting some changes.

xmpp.js file | annotate | diff | comparison | revisions
--- a/xmpp.js	Sun Feb 21 15:25:11 2010 -0800
+++ b/xmpp.js	Wed Feb 24 22:04:06 2010 -0800
@@ -62,7 +62,6 @@
 			{
 				if(stream.opened)
 					stanza = xmpp.stanza(tagname, attr);
-                /* else if(tagname == "stream") */
 				else if(tagname == "stream" && uri == xmpp.xmlns.streams)
 				{
 					stream.opened = true;
@@ -117,9 +116,6 @@
 	this.host = host || "localhost";
 	this.port = port || 5347;
 	
-	/** this.socket = tcp.createConnection();
-    this.socket.close() **/
-	
 	this.stream = new xmpp.Stream({
 		opened: recontext(this, this._stream_opened),
 		stanza: recontext(this, this._handle_stanza),
@@ -139,16 +135,18 @@
 		this.connect_callback = callback;
 		
 		var conn = this;
+
+        // Note that tcp.createConnection also initiates the connection.
+        // This doesn't appear to create problems with adding listeners
+        // afterward, but should be kept in mind should any arise.
         this.socket = tcp.createConnection(this.port, this.host)
+
 		this.socket.addListener("connect", recontext(this, conn._socket_connected));
 		this.socket.addListener("disconnect", recontext(this, conn._socket_disconnected));
 		this.socket.addListener("data", recontext(this, conn._socket_received));
 		
 		this.handlers = [];
 		
-		// Connect TCP socket
-		// this.socket.connect(this.port, this.host);
-	
 		this._setStatus(xmpp.Status.CONNECTING);
 	},
 	
@@ -316,6 +314,9 @@
 xmpp.StanzaBuilder.prototype = {
     s: function (name, attr)
     {
+        // This function was created because c() doesn't seem to work for adding
+        // multiple children on the same level with each other. This is just a
+        // quick fix mostly to get chatstates working.
 		var s = new xmpp.StanzaBuilder(name, attr);
         var parent = this;
         parent.tags.push(s);

mercurial