Created
October 4, 2019 17:42
-
-
Save wellington1993/24dade5aba3b64986c6ed3878e677d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright: Hiroshi Ichikawa <http://gimite.net/en/> | |
License: New BSD License | |
Reference: http://dev.w3.org/html5/websockets/ | |
Reference: http://tools.ietf.org/html/rfc6455 | |
*/ | |
/* Version 1.4.3.15 */ | |
'use strict';(function(){var c;c=window.WEB_SOCKET_LOGGER?window.WEB_SOCKET_LOGGER:window.console&&window.console.log&&window.console.error?window.console:{log:function(){},error:function(){}};11>swfobject.getFlashPlayerVersion().major?c.error("Flash Player >= 11.1.0 is required."):("file:"==location.protocol&&c.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),window.FlashWebSocket=function(a, | |
b,e,c,f){var d=this;d.d=FlashWebSocket.p++;FlashWebSocket.k[d.d]=d;d.readyState=FlashWebSocket.CONNECTING;d.bufferedAmount=0;d.b={};b?"string"==typeof b&&(b=[b]):b=[];d.c=setTimeout(function(){FlashWebSocket.h(function(){d.c=null;FlashWebSocket.a.create(d.d,a,b,e||null,c||0,f||null)})},0)},FlashWebSocket.prototype.send=function(a){if(this.readyState==FlashWebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";a=FlashWebSocket.a.send(this.d,encodeURIComponent(a)); | |
if(0>a)return!0;this.bufferedAmount+=a;return!1},FlashWebSocket.prototype.close=function(){this.c?(clearTimeout(this.c),this.c=null,this.readyState=FlashWebSocket.CLOSED):this.readyState!=FlashWebSocket.CLOSED&&this.readyState!=FlashWebSocket.f&&(this.readyState=FlashWebSocket.f,FlashWebSocket.a.close(this.d))},FlashWebSocket.prototype.addEventListener=function(a,b){a in this.b||(this.b[a]=[]);this.b[a].push(b)},FlashWebSocket.prototype.removeEventListener=function(a,b){if(a in this.b)for(var e=this.b[a], | |
c=e.length-1;0<=c;--c)if(e[c]===b){e.splice(c,1);break}},FlashWebSocket.prototype.dispatchEvent=function(a){for(var b=this.b[a.type]||[],c=0;c<b.length;++c)b[c](a);(b=this["on"+a.type])&&b.apply(this,[a])},FlashWebSocket.prototype.m=function(a){"readyState"in a&&(this.readyState=a.readyState);"protocol"in a&&(this.protocol=a.protocol);var b;if("open"==a.type||"error"==a.type)b=this.i(a.type);else if("close"==a.type)b=this.i("close"),b.wasClean=a.wasClean?!0:!1,b.code=a.code,b.reason=a.reason;else if("message"== | |
a.type)b=this.l(decodeURIComponent(a.message));else throw"unknown event type: "+a.type;this.dispatchEvent(b)},FlashWebSocket.prototype.i=function(a){if(document.createEvent&&window.r){var b=document.createEvent("Event");b.initEvent(a,!1,!1);return b}return{type:a,bubbles:!1,cancelable:!1}},FlashWebSocket.prototype.l=function(a){if(window.g)return new MessageEvent("message",{data:a,origin:window});if(document.createEvent&&window.g&&!window.opera){var b=document.createEvent("MessageEvent");if(b.initMessageEvent)return b.initMessageEvent("message", | |
!1,!1,a,null,null,window,null),b}return window.g&&"function"==typeof MessageEvent&&!window.opera?new MessageEvent("message",{view:window,bubbles:!1,cancelable:!1,data:a}):{type:"message",data:a,bubbles:!1,cancelable:!1}},FlashWebSocket.CONNECTING=0,FlashWebSocket.OPEN=1,FlashWebSocket.f=2,FlashWebSocket.CLOSED=3,FlashWebSocket.s=!0,FlashWebSocket.j=!1,FlashWebSocket.a=null,FlashWebSocket.k={},FlashWebSocket.e=[],FlashWebSocket.p=0,FlashWebSocket.t=function(a){FlashWebSocket.h(function(){FlashWebSocket.a.loadManualPolicyFile(a)})}, | |
FlashWebSocket.n=function(){if(!FlashWebSocket.j)if(FlashWebSocket.j=!0,FlashWebSocket.q&&(window.WEB_SOCKET_SWF_LOCATION=FlashWebSocket.q),window.WEB_SOCKET_SWF_LOCATION){if(!window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR&&!window.WEB_SOCKET_SWF_LOCATION.match(/(^|\/)WebSocketMainInsecure\.swf(\?.*)?$/)&&window.WEB_SOCKET_SWF_LOCATION.match(/^\w+:\/\/([^\/]+)/)){var a=RegExp.$1;location.host!=a&&c.error("[WebSocket] You must host HTML and WebSocketMain.swf in the same host ('"+location.host+"' != '"+ | |
a+"'). See also 'How to host HTML file and SWF file in different domains' section in README.md. If you use WebSocketMainInsecure.swf, you can suppress this message by WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;")}a=document.createElement("div");a.id="webSocketContainer";a.style.position="absolute";FlashWebSocket.o()?(a.style.left="0px",a.style.top="0px"):(a.style.left="-100px",a.style.top="-100px");var b=document.createElement("div");b.id="webSocketFlash";a.appendChild(b);document.body.appendChild(a); | |
swfobject.embedSWF(window.WEB_SOCKET_SWF_LOCATION,"webSocketFlash","1","1","11.1.0",null,null,{hasPriority:!0,swliveconnect:!0,allowScriptAccess:"always"},null,function(a){a.success||c.error("[WebSocket] swfobject.embedSWF failed")})}else c.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf")},FlashWebSocket.__onFlashInitialized=function(){setTimeout(function(){FlashWebSocket.a=document.getElementById("webSocketFlash");FlashWebSocket.a.setCallerUrl(location.href);FlashWebSocket.a.setUserAgent(navigator.userAgent); | |
FlashWebSocket.a.setDebug(!!window.WEB_SOCKET_DEBUG);for(var a=0;a<FlashWebSocket.e.length;++a)FlashWebSocket.e[a]();FlashWebSocket.e=[]},0)},FlashWebSocket.__onFlashEvent=function(){setTimeout(function(){try{for(var a=FlashWebSocket.a.receiveEvents(),b=0;b<a.length;++b)FlashWebSocket.k[a[b].webSocketId].m(a[b])}catch(e){c.error(e)}},0);return!0},FlashWebSocket.__log=function(a){c.log(decodeURIComponent(a))},FlashWebSocket.__error=function(a){c.error(decodeURIComponent(a))},FlashWebSocket.h=function(a){FlashWebSocket.a? | |
a():FlashWebSocket.e.push(a)},FlashWebSocket.o=function(){if(!window.navigator||!window.navigator.mimeTypes)return!1;var a=window.navigator.mimeTypes["application/x-shockwave-flash"];return a&&a.enabledPlugin&&a.enabledPlugin.filename?a.enabledPlugin.filename.match(/flashlite/i)?!0:!1:!1},window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION||swfobject.addDomLoadEvent(function(){FlashWebSocket.n()}))})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment