comparison script2.js @ 6:24aa8dccb170

Make XMPP actually work.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 31 Jan 2012 15:59:28 +0100
parents 03ef53b969bd
children 853dcbe8f06f
comparison
equal deleted inserted replaced
5:03ef53b969bd 6:24aa8dccb170
107 "</iq>"; 107 "</iq>";
108 conn.send(initiate); 108 conn.send(initiate);
109 }; 109 };
110 110
111 var accept = function(sid) { 111 var accept = function(sid) {
112 var accept = "<iq to='" + documents[sid].initiator + "' type='set'>" + 112 var doc = documents[sid];
113 doc.empty();
114 var accept = "<iq to='" + doc.initiator + "' type='set'>" +
113 "<jingle xmlns='" + Lightstring.NS.jingle.main + "'" + 115 "<jingle xmlns='" + Lightstring.NS.jingle.main + "'" +
114 " action='session-accept'" + 116 " action='session-accept'" +
115 " initiator='" + documents[sid].initiator + "'" + 117 " initiator='" + doc.initiator + "'" +
116 " sid='" + sid + "'>" + 118 " sid='" + sid + "'>" +
117 "<content creator='initiator' name='" + documents[sid].name + "'>" + 119 "<content creator='initiator' name='" + documents[sid].name + "'>" +
118 "<description xmlns='" + Lightstring.NS.jingle.apps.xhtml + "'/>" + 120 "<description xmlns='" + Lightstring.NS.jingle.apps.xhtml + "'/>" +
119 "<transport xmlns='" + Lightstring.NS.jingle.transports.sxe + "'>" + 121 "<transport xmlns='" + Lightstring.NS.jingle.transports.sxe + "'>" +
120 "<host>" + documents[sid].host + "</host>" + 122 "<host>" + doc.host + "</host>" +
121 "</transport>" + 123 "</transport>" +
122 "</content>" + 124 "</content>" +
123 "</jingle>" + 125 "</jingle>" +
124 "</iq>"; 126 "</iq>";
125 conn.send(accept, function(stanza) { 127 conn.send(accept, function(stanza) {
291 "</sxe>" + 293 "</sxe>" +
292 "</message>"; 294 "</message>";
293 conn.send(message); 295 conn.send(message);
294 break; 296 break;
295 case 'accept-state': 297 case 'accept-state':
298 var initialState = doc.createState([]).map(function(element) {
299 return Lightstring.DOM2XML(element);
300 }).join('');
296 var message = "<message to='" + from + "'" + 301 var message = "<message to='" + from + "'" +
297 " type='" + type + "'>" + 302 " type='" + type + "'>" +
298 "<sxe xmlns='" + Lightstring.NS.sxe + "'" + 303 "<sxe xmlns='" + Lightstring.NS.sxe + "'" +
299 " id='" + Lightstring.newId('sxe') + "'" + 304 " id='" + Lightstring.newId('sxe') + "'" +
300 " session='" + sid + "'>" + 305 " session='" + sid + "'>" +
301 "<state>" + 306 "<state>" +
302 "<document-begin prolog='" + doc.prolog + "'/>" + 307 "<document-begin prolog='" + doc.prolog + "'/>" +
303 //TODO: support non-empty documents. 308 initialState +
304 "<document-end last-sender='' last-id=''/>" + 309 "<document-end last-sender='' last-id=''/>" +
305 "</state>" + 310 "</state>" +
306 "</sxe>" + 311 "</sxe>" +
307 "</message>"; 312 "</message>";
308 conn.send(message); 313 conn.send(message);