diff -r 917f370a7631 -r aaad945d10ba xmpp.js --- a/xmpp.js Wed Feb 10 15:23:19 2010 +0000 +++ b/xmpp.js Sun Feb 21 15:25:11 2010 -0800 @@ -18,7 +18,8 @@ xmpp.xmlns = { streams: "http://etherx.jabber.org/streams", - component_accept: "jabber:component:accept" + component_accept: "jabber:component:accept", + chatstates: "http://jabber.org/protocol/chatstates" }; xmpp.Status = { @@ -61,6 +62,7 @@ { if(stream.opened) stanza = xmpp.stanza(tagname, attr); + /* else if(tagname == "stream") */ else if(tagname == "stream" && uri == xmpp.xmlns.streams) { stream.opened = true; @@ -115,7 +117,8 @@ this.host = host || "localhost"; this.port = port || 5347; - this.socket = tcp.createConnection(); + /** this.socket = tcp.createConnection(); + this.socket.close() **/ this.stream = new xmpp.Stream({ opened: recontext(this, this._stream_opened), @@ -136,14 +139,15 @@ this.connect_callback = callback; var conn = this; + 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("receive", recontext(this, conn._socket_received)); + this.socket.addListener("data", recontext(this, conn._socket_received)); this.handlers = []; // Connect TCP socket - this.socket.connect(this.port, this.host); + // this.socket.connect(this.port, this.host); this._setStatus(xmpp.Status.CONNECTING); }, @@ -151,7 +155,7 @@ send: function (data) { this.debug("SND: "+data); - this.socket.send(data.toString()); + this.socket.write(data.toString()); }, sendIQ: function (iq, on_result, on_error) @@ -223,6 +227,7 @@ this._setStatus(xmpp.Status.AUTHENTICATING); var handshake = sha1.hex(attr.id + this.password); this.debug("Sending authentication token..."); + this.debug("with id: '"+attr.id+"' and pass: '"+this.password+"'") this.send(""+handshake+""); }, @@ -309,6 +314,16 @@ }; xmpp.StanzaBuilder.prototype = { + s: function (name, attr) + { + var s = new xmpp.StanzaBuilder(name, attr); + var parent = this; + parent.tags.push(s); + parent.children.push(s); + this.last_node.push(s); + return this + }, + c: function (name, attr) { var s = new xmpp.StanzaBuilder(name, attr);