PageRenderTime 44ms CodeModel.GetById 38ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/transports/flashsocket.js

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
JavaScript | 54 lines | 38 code | 9 blank | 7 comment | 8 complexity | 6fdd850777d15ebdbb4ab0127d67301e MD5 | raw file
 1/**
 2 * Socket.IO client
 3 * 
 4 * @author Guillermo Rauch <guillermo@learnboost.com>
 5 * @license The MIT license.
 6 * @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com>
 7 */
 8
 9(function(){
10	var io = this.io;
11	
12	var Flashsocket = io.Transport.flashsocket = function(){
13		io.Transport.websocket.apply(this, arguments);
14	};
15	
16	io.util.inherit(Flashsocket, io.Transport.websocket);
17	
18	Flashsocket.prototype.type = 'flashsocket';
19	
20	Flashsocket.prototype.connect = function(){
21		var self = this, args = arguments;
22		WebSocket.__addTask(function(){
23			io.Transport.websocket.prototype.connect.apply(self, args);
24		});
25		return this;
26	};
27	
28	Flashsocket.prototype.send = function(){
29		var self = this, args = arguments;
30		WebSocket.__addTask(function(){
31			io.Transport.websocket.prototype.send.apply(self, args);
32		});
33		return this;
34	};
35	
36	Flashsocket.check = function(){
37		if (typeof WebSocket == 'undefined' || !('__addTask' in WebSocket)) return false;
38		if (io.util.opera) return false; // opera is buggy with this transport
39		if ('navigator' in window && 'plugins' in navigator && navigator.plugins['Shockwave Flash']){
40			return !!navigator.plugins['Shockwave Flash'].description;
41	  }
42		if ('ActiveXObject' in window) {
43			try {
44				return !!new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
45			} catch (e) {}
46		}
47		return false;
48	};
49	
50	Flashsocket.xdomainCheck = function(){
51		return true;
52	};
53	
54})();