comparison lightstring.js @ 39:5e32481b8a92

Better WebSocket feature discovering and Opera support
author Sonny Piers <sonny.piers@gmail.com>
date Tue, 31 Jan 2012 04:12:34 +0100
parents 6773e5bc2ca0
children e02bfcb78428
comparison
equal deleted inserted replaced
38:d38597574322 39:5e32481b8a92
264 throw 'Lightstring: Connection.password is undefined.'; 264 throw 'Lightstring: Connection.password is undefined.';
265 if (!this.service) 265 if (!this.service)
266 throw 'Lightstring: Connection.service is undefined.'; 266 throw 'Lightstring: Connection.service is undefined.';
267 267
268 //"Bug 695635 - tracking bug: unprefix WebSockets" https://bugzil.la/695635 268 //"Bug 695635 - tracking bug: unprefix WebSockets" https://bugzil.la/695635
269 try { 269 if(typeof(MozWebSocket) == "function") {
270 this.socket = new MozWebSocket(this.service, 'xmpp');
271 }
272 else if(typeof(WebSocket) == "function") {
270 this.socket = new WebSocket(this.service, 'xmpp'); 273 this.socket = new WebSocket(this.service, 'xmpp');
271 } 274 }
272 catch (error) { 275 else {
273 this.socket = new MozWebSocket(this.service, 'xmpp'); 276 throw new Error('WebSocket not available.');
274 } 277 }
275 278
276 var that = this; 279 var that = this;
277 this.socket.addEventListener('open', function() { 280 this.socket.addEventListener('open', function() {
278 //TODO: if (this.protocol !== 'xmpp') 281 //TODO: if (this.protocol !== 'xmpp')