xmpp.js

changeset 6
ec839631a35f
parent 5
20a58dcf2323
child 7
394b0c8cad04
equal deleted inserted replaced
5:20a58dcf2323 6:ec839631a35f
133 var conn = this; 133 var conn = this;
134 this.socket.addListener("connect", recontext(this, conn._socket_connected)); 134 this.socket.addListener("connect", recontext(this, conn._socket_connected));
135 this.socket.addListener("disconnect", recontext(this, conn._socket_disconnected)); 135 this.socket.addListener("disconnect", recontext(this, conn._socket_disconnected));
136 this.socket.addListener("receive", recontext(this, conn._socket_received)); 136 this.socket.addListener("receive", recontext(this, conn._socket_received));
137 137
138 this.handlers = [];
139
138 // Connect TCP socket 140 // Connect TCP socket
139 this.socket.connect(this.port, this.host); 141 this.socket.connect(this.port, this.host);
140 142
141 this._setStatus(xmpp.Status.CONNECTING); 143 this._setStatus(xmpp.Status.CONNECTING);
142 }, 144 },
145 { 147 {
146 this.debug("SND: "+data); 148 this.debug("SND: "+data);
147 this.socket.send(data.toString()); 149 this.socket.send(data.toString());
148 }, 150 },
149 151
152
153 addHandler: function (handler, ns, name, type, id, from, options)
154 {
155 return this.handlers.push({
156 callback: handler,
157 xmlns: ns,
158 name: name,
159 type: type,
160 id: id,
161 from: from,
162 matchBare: options && options.matchBare});
163 },
150 164
151 getUniqueId: function (suffix) 165 getUniqueId: function (suffix)
152 { 166 {
153 return ++this._uniqueId + (suffix?(":"+suffix):""); 167 return ++this._uniqueId + (suffix?(":"+suffix):"");
154 }, 168 },

mercurial