socket.io-rails 0.9.11 → 0.9.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62c8bfa15f4b34e8d1efd04f70a5714a3d5fb3d8
4
+ data.tar.gz: 64761ae75bea4fed0489bd66ba2faf62125c2f4d
5
+ SHA512:
6
+ metadata.gz: 3291c75301a238ec1f5fa6d2ce4b916f301dc350e411dd1aa0c45546b7ec25820fd5e504d42b38d79dc3fc3cb92aa8f3e176122fbc1c3262fa8e8343ebdd35a2
7
+ data.tar.gz: 930b3db28beb9bf2ef475b0ed8665dd631f80cc99372193ab5a39643d6209363b054db55f5ab367c8e8a87c06bc86fdef53892c253237809b358ee37fdf80e8e
@@ -1,5 +1,5 @@
1
1
  module Socketio
2
2
  module Rails
3
- VERSION = "0.9.11"
3
+ VERSION = "0.9.16"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- /*! Socket.IO.js build:0.9.11, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
1
+ /*! Socket.IO.js build:0.9.16, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
2
2
 
3
3
  var io = ('undefined' === typeof module ? {} : module.exports);
4
4
  (function() {
@@ -25,7 +25,7 @@ var io = ('undefined' === typeof module ? {} : module.exports);
25
25
  * @api public
26
26
  */
27
27
 
28
- io.version = '0.9.11';
28
+ io.version = '0.9.16';
29
29
 
30
30
  /**
31
31
  * Protocol implemented.
@@ -2498,6 +2498,552 @@ var io = ('undefined' === typeof module ? {} : module.exports);
2498
2498
  , this
2499
2499
  );
2500
2500
 
2501
+ /**
2502
+ * socket.io
2503
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
2504
+ * MIT Licensed
2505
+ */
2506
+
2507
+ (function (exports, io) {
2508
+
2509
+ /**
2510
+ * Expose constructor.
2511
+ */
2512
+
2513
+ exports.flashsocket = Flashsocket;
2514
+
2515
+ /**
2516
+ * The FlashSocket transport. This is a API wrapper for the HTML5 WebSocket
2517
+ * specification. It uses a .swf file to communicate with the server. If you want
2518
+ * to serve the .swf file from a other server than where the Socket.IO script is
2519
+ * coming from you need to use the insecure version of the .swf. More information
2520
+ * about this can be found on the github page.
2521
+ *
2522
+ * @constructor
2523
+ * @extends {io.Transport.websocket}
2524
+ * @api public
2525
+ */
2526
+
2527
+ function Flashsocket () {
2528
+ io.Transport.websocket.apply(this, arguments);
2529
+ };
2530
+
2531
+ /**
2532
+ * Inherits from Transport.
2533
+ */
2534
+
2535
+ io.util.inherit(Flashsocket, io.Transport.websocket);
2536
+
2537
+ /**
2538
+ * Transport name
2539
+ *
2540
+ * @api public
2541
+ */
2542
+
2543
+ Flashsocket.prototype.name = 'flashsocket';
2544
+
2545
+ /**
2546
+ * Disconnect the established `FlashSocket` connection. This is done by adding a
2547
+ * new task to the FlashSocket. The rest will be handled off by the `WebSocket`
2548
+ * transport.
2549
+ *
2550
+ * @returns {Transport}
2551
+ * @api public
2552
+ */
2553
+
2554
+ Flashsocket.prototype.open = function () {
2555
+ var self = this
2556
+ , args = arguments;
2557
+
2558
+ WebSocket.__addTask(function () {
2559
+ io.Transport.websocket.prototype.open.apply(self, args);
2560
+ });
2561
+ return this;
2562
+ };
2563
+
2564
+ /**
2565
+ * Sends a message to the Socket.IO server. This is done by adding a new
2566
+ * task to the FlashSocket. The rest will be handled off by the `WebSocket`
2567
+ * transport.
2568
+ *
2569
+ * @returns {Transport}
2570
+ * @api public
2571
+ */
2572
+
2573
+ Flashsocket.prototype.send = function () {
2574
+ var self = this, args = arguments;
2575
+ WebSocket.__addTask(function () {
2576
+ io.Transport.websocket.prototype.send.apply(self, args);
2577
+ });
2578
+ return this;
2579
+ };
2580
+
2581
+ /**
2582
+ * Disconnects the established `FlashSocket` connection.
2583
+ *
2584
+ * @returns {Transport}
2585
+ * @api public
2586
+ */
2587
+
2588
+ Flashsocket.prototype.close = function () {
2589
+ WebSocket.__tasks.length = 0;
2590
+ io.Transport.websocket.prototype.close.call(this);
2591
+ return this;
2592
+ };
2593
+
2594
+ /**
2595
+ * The WebSocket fall back needs to append the flash container to the body
2596
+ * element, so we need to make sure we have access to it. Or defer the call
2597
+ * until we are sure there is a body element.
2598
+ *
2599
+ * @param {Socket} socket The socket instance that needs a transport
2600
+ * @param {Function} fn The callback
2601
+ * @api private
2602
+ */
2603
+
2604
+ Flashsocket.prototype.ready = function (socket, fn) {
2605
+ function init () {
2606
+ var options = socket.options
2607
+ , port = options['flash policy port']
2608
+ , path = [
2609
+ 'http' + (options.secure ? 's' : '') + ':/'
2610
+ , options.host + ':' + options.port
2611
+ , options.resource
2612
+ , 'static/flashsocket'
2613
+ , 'WebSocketMain' + (socket.isXDomain() ? 'Insecure' : '') + '.swf'
2614
+ ];
2615
+
2616
+ // Only start downloading the swf file when the checked that this browser
2617
+ // actually supports it
2618
+ if (!Flashsocket.loaded) {
2619
+ if (typeof WEB_SOCKET_SWF_LOCATION === 'undefined') {
2620
+ // Set the correct file based on the XDomain settings
2621
+ WEB_SOCKET_SWF_LOCATION = path.join('/');
2622
+ }
2623
+
2624
+ if (port !== 843) {
2625
+ WebSocket.loadFlashPolicyFile('xmlsocket://' + options.host + ':' + port);
2626
+ }
2627
+
2628
+ WebSocket.__initialize();
2629
+ Flashsocket.loaded = true;
2630
+ }
2631
+
2632
+ fn.call(self);
2633
+ }
2634
+
2635
+ var self = this;
2636
+ if (document.body) return init();
2637
+
2638
+ io.util.load(init);
2639
+ };
2640
+
2641
+ /**
2642
+ * Check if the FlashSocket transport is supported as it requires that the Adobe
2643
+ * Flash Player plug-in version `10.0.0` or greater is installed. And also check if
2644
+ * the polyfill is correctly loaded.
2645
+ *
2646
+ * @returns {Boolean}
2647
+ * @api public
2648
+ */
2649
+
2650
+ Flashsocket.check = function () {
2651
+ if (
2652
+ typeof WebSocket == 'undefined'
2653
+ || !('__initialize' in WebSocket) || !swfobject
2654
+ ) return false;
2655
+
2656
+ return swfobject.getFlashPlayerVersion().major >= 10;
2657
+ };
2658
+
2659
+ /**
2660
+ * Check if the FlashSocket transport can be used as cross domain / cross origin
2661
+ * transport. Because we can't see which type (secure or insecure) of .swf is used
2662
+ * we will just return true.
2663
+ *
2664
+ * @returns {Boolean}
2665
+ * @api public
2666
+ */
2667
+
2668
+ Flashsocket.xdomainCheck = function () {
2669
+ return true;
2670
+ };
2671
+
2672
+ /**
2673
+ * Disable AUTO_INITIALIZATION
2674
+ */
2675
+
2676
+ if (typeof window != 'undefined') {
2677
+ WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
2678
+ }
2679
+
2680
+ /**
2681
+ * Add the transport to your public io.transports array.
2682
+ *
2683
+ * @api private
2684
+ */
2685
+
2686
+ io.transports.push('flashsocket');
2687
+ })(
2688
+ 'undefined' != typeof io ? io.Transport : module.exports
2689
+ , 'undefined' != typeof io ? io : module.parent.exports
2690
+ );
2691
+ /* SWFObject v2.2 <http://code.google.com/p/swfobject/>
2692
+ is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
2693
+ */
2694
+ if ('undefined' != typeof window) {
2695
+ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O[(['Active'].concat('Object').join('X'))]!=D){try{var ad=new window[(['Active'].concat('Object').join('X'))](W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?(['Active'].concat('').join('X')):"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
2696
+ }
2697
+ // Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
2698
+ // License: New BSD License
2699
+ // Reference: http://dev.w3.org/html5/websockets/
2700
+ // Reference: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
2701
+
2702
+ (function() {
2703
+
2704
+ if ('undefined' == typeof window || window.WebSocket) return;
2705
+
2706
+ var console = window.console;
2707
+ if (!console || !console.log || !console.error) {
2708
+ console = {log: function(){ }, error: function(){ }};
2709
+ }
2710
+
2711
+ if (!swfobject.hasFlashPlayerVersion("10.0.0")) {
2712
+ console.error("Flash Player >= 10.0.0 is required.");
2713
+ return;
2714
+ }
2715
+ if (location.protocol == "file:") {
2716
+ console.error(
2717
+ "WARNING: web-socket-js doesn't work in file:///... URL " +
2718
+ "unless you set Flash Security Settings properly. " +
2719
+ "Open the page via Web server i.e. http://...");
2720
+ }
2721
+
2722
+ /**
2723
+ * This class represents a faux web socket.
2724
+ * @param {string} url
2725
+ * @param {array or string} protocols
2726
+ * @param {string} proxyHost
2727
+ * @param {int} proxyPort
2728
+ * @param {string} headers
2729
+ */
2730
+ WebSocket = function(url, protocols, proxyHost, proxyPort, headers) {
2731
+ var self = this;
2732
+ self.__id = WebSocket.__nextId++;
2733
+ WebSocket.__instances[self.__id] = self;
2734
+ self.readyState = WebSocket.CONNECTING;
2735
+ self.bufferedAmount = 0;
2736
+ self.__events = {};
2737
+ if (!protocols) {
2738
+ protocols = [];
2739
+ } else if (typeof protocols == "string") {
2740
+ protocols = [protocols];
2741
+ }
2742
+ // Uses setTimeout() to make sure __createFlash() runs after the caller sets ws.onopen etc.
2743
+ // Otherwise, when onopen fires immediately, onopen is called before it is set.
2744
+ setTimeout(function() {
2745
+ WebSocket.__addTask(function() {
2746
+ WebSocket.__flash.create(
2747
+ self.__id, url, protocols, proxyHost || null, proxyPort || 0, headers || null);
2748
+ });
2749
+ }, 0);
2750
+ };
2751
+
2752
+ /**
2753
+ * Send data to the web socket.
2754
+ * @param {string} data The data to send to the socket.
2755
+ * @return {boolean} True for success, false for failure.
2756
+ */
2757
+ WebSocket.prototype.send = function(data) {
2758
+ if (this.readyState == WebSocket.CONNECTING) {
2759
+ throw "INVALID_STATE_ERR: Web Socket connection has not been established";
2760
+ }
2761
+ // We use encodeURIComponent() here, because FABridge doesn't work if
2762
+ // the argument includes some characters. We don't use escape() here
2763
+ // because of this:
2764
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Functions#escape_and_unescape_Functions
2765
+ // But it looks decodeURIComponent(encodeURIComponent(s)) doesn't
2766
+ // preserve all Unicode characters either e.g. "\uffff" in Firefox.
2767
+ // Note by wtritch: Hopefully this will not be necessary using ExternalInterface. Will require
2768
+ // additional testing.
2769
+ var result = WebSocket.__flash.send(this.__id, encodeURIComponent(data));
2770
+ if (result < 0) { // success
2771
+ return true;
2772
+ } else {
2773
+ this.bufferedAmount += result;
2774
+ return false;
2775
+ }
2776
+ };
2777
+
2778
+ /**
2779
+ * Close this web socket gracefully.
2780
+ */
2781
+ WebSocket.prototype.close = function() {
2782
+ if (this.readyState == WebSocket.CLOSED || this.readyState == WebSocket.CLOSING) {
2783
+ return;
2784
+ }
2785
+ this.readyState = WebSocket.CLOSING;
2786
+ WebSocket.__flash.close(this.__id);
2787
+ };
2788
+
2789
+ /**
2790
+ * Implementation of {@link <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">DOM 2 EventTarget Interface</a>}
2791
+ *
2792
+ * @param {string} type
2793
+ * @param {function} listener
2794
+ * @param {boolean} useCapture
2795
+ * @return void
2796
+ */
2797
+ WebSocket.prototype.addEventListener = function(type, listener, useCapture) {
2798
+ if (!(type in this.__events)) {
2799
+ this.__events[type] = [];
2800
+ }
2801
+ this.__events[type].push(listener);
2802
+ };
2803
+
2804
+ /**
2805
+ * Implementation of {@link <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">DOM 2 EventTarget Interface</a>}
2806
+ *
2807
+ * @param {string} type
2808
+ * @param {function} listener
2809
+ * @param {boolean} useCapture
2810
+ * @return void
2811
+ */
2812
+ WebSocket.prototype.removeEventListener = function(type, listener, useCapture) {
2813
+ if (!(type in this.__events)) return;
2814
+ var events = this.__events[type];
2815
+ for (var i = events.length - 1; i >= 0; --i) {
2816
+ if (events[i] === listener) {
2817
+ events.splice(i, 1);
2818
+ break;
2819
+ }
2820
+ }
2821
+ };
2822
+
2823
+ /**
2824
+ * Implementation of {@link <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">DOM 2 EventTarget Interface</a>}
2825
+ *
2826
+ * @param {Event} event
2827
+ * @return void
2828
+ */
2829
+ WebSocket.prototype.dispatchEvent = function(event) {
2830
+ var events = this.__events[event.type] || [];
2831
+ for (var i = 0; i < events.length; ++i) {
2832
+ events[i](event);
2833
+ }
2834
+ var handler = this["on" + event.type];
2835
+ if (handler) handler(event);
2836
+ };
2837
+
2838
+ /**
2839
+ * Handles an event from Flash.
2840
+ * @param {Object} flashEvent
2841
+ */
2842
+ WebSocket.prototype.__handleEvent = function(flashEvent) {
2843
+ if ("readyState" in flashEvent) {
2844
+ this.readyState = flashEvent.readyState;
2845
+ }
2846
+ if ("protocol" in flashEvent) {
2847
+ this.protocol = flashEvent.protocol;
2848
+ }
2849
+
2850
+ var jsEvent;
2851
+ if (flashEvent.type == "open" || flashEvent.type == "error") {
2852
+ jsEvent = this.__createSimpleEvent(flashEvent.type);
2853
+ } else if (flashEvent.type == "close") {
2854
+ // TODO implement jsEvent.wasClean
2855
+ jsEvent = this.__createSimpleEvent("close");
2856
+ } else if (flashEvent.type == "message") {
2857
+ var data = decodeURIComponent(flashEvent.message);
2858
+ jsEvent = this.__createMessageEvent("message", data);
2859
+ } else {
2860
+ throw "unknown event type: " + flashEvent.type;
2861
+ }
2862
+
2863
+ this.dispatchEvent(jsEvent);
2864
+ };
2865
+
2866
+ WebSocket.prototype.__createSimpleEvent = function(type) {
2867
+ if (document.createEvent && window.Event) {
2868
+ var event = document.createEvent("Event");
2869
+ event.initEvent(type, false, false);
2870
+ return event;
2871
+ } else {
2872
+ return {type: type, bubbles: false, cancelable: false};
2873
+ }
2874
+ };
2875
+
2876
+ WebSocket.prototype.__createMessageEvent = function(type, data) {
2877
+ if (document.createEvent && window.MessageEvent && !window.opera) {
2878
+ var event = document.createEvent("MessageEvent");
2879
+ event.initMessageEvent("message", false, false, data, null, null, window, null);
2880
+ return event;
2881
+ } else {
2882
+ // IE and Opera, the latter one truncates the data parameter after any 0x00 bytes.
2883
+ return {type: type, data: data, bubbles: false, cancelable: false};
2884
+ }
2885
+ };
2886
+
2887
+ /**
2888
+ * Define the WebSocket readyState enumeration.
2889
+ */
2890
+ WebSocket.CONNECTING = 0;
2891
+ WebSocket.OPEN = 1;
2892
+ WebSocket.CLOSING = 2;
2893
+ WebSocket.CLOSED = 3;
2894
+
2895
+ WebSocket.__flash = null;
2896
+ WebSocket.__instances = {};
2897
+ WebSocket.__tasks = [];
2898
+ WebSocket.__nextId = 0;
2899
+
2900
+ /**
2901
+ * Load a new flash security policy file.
2902
+ * @param {string} url
2903
+ */
2904
+ WebSocket.loadFlashPolicyFile = function(url){
2905
+ WebSocket.__addTask(function() {
2906
+ WebSocket.__flash.loadManualPolicyFile(url);
2907
+ });
2908
+ };
2909
+
2910
+ /**
2911
+ * Loads WebSocketMain.swf and creates WebSocketMain object in Flash.
2912
+ */
2913
+ WebSocket.__initialize = function() {
2914
+ if (WebSocket.__flash) return;
2915
+
2916
+ if (WebSocket.__swfLocation) {
2917
+ // For backword compatibility.
2918
+ window.WEB_SOCKET_SWF_LOCATION = WebSocket.__swfLocation;
2919
+ }
2920
+ if (!window.WEB_SOCKET_SWF_LOCATION) {
2921
+ console.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");
2922
+ return;
2923
+ }
2924
+ var container = document.createElement("div");
2925
+ container.id = "webSocketContainer";
2926
+ // Hides Flash box. We cannot use display: none or visibility: hidden because it prevents
2927
+ // Flash from loading at least in IE. So we move it out of the screen at (-100, -100).
2928
+ // But this even doesn't work with Flash Lite (e.g. in Droid Incredible). So with Flash
2929
+ // Lite, we put it at (0, 0). This shows 1x1 box visible at left-top corner but this is
2930
+ // the best we can do as far as we know now.
2931
+ container.style.position = "absolute";
2932
+ if (WebSocket.__isFlashLite()) {
2933
+ container.style.left = "0px";
2934
+ container.style.top = "0px";
2935
+ } else {
2936
+ container.style.left = "-100px";
2937
+ container.style.top = "-100px";
2938
+ }
2939
+ var holder = document.createElement("div");
2940
+ holder.id = "webSocketFlash";
2941
+ container.appendChild(holder);
2942
+ document.body.appendChild(container);
2943
+ // See this article for hasPriority:
2944
+ // http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html
2945
+ swfobject.embedSWF(
2946
+ WEB_SOCKET_SWF_LOCATION,
2947
+ "webSocketFlash",
2948
+ "1" /* width */,
2949
+ "1" /* height */,
2950
+ "10.0.0" /* SWF version */,
2951
+ null,
2952
+ null,
2953
+ {hasPriority: true, swliveconnect : true, allowScriptAccess: "always"},
2954
+ null,
2955
+ function(e) {
2956
+ if (!e.success) {
2957
+ console.error("[WebSocket] swfobject.embedSWF failed");
2958
+ }
2959
+ });
2960
+ };
2961
+
2962
+ /**
2963
+ * Called by Flash to notify JS that it's fully loaded and ready
2964
+ * for communication.
2965
+ */
2966
+ WebSocket.__onFlashInitialized = function() {
2967
+ // We need to set a timeout here to avoid round-trip calls
2968
+ // to flash during the initialization process.
2969
+ setTimeout(function() {
2970
+ WebSocket.__flash = document.getElementById("webSocketFlash");
2971
+ WebSocket.__flash.setCallerUrl(location.href);
2972
+ WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);
2973
+ for (var i = 0; i < WebSocket.__tasks.length; ++i) {
2974
+ WebSocket.__tasks[i]();
2975
+ }
2976
+ WebSocket.__tasks = [];
2977
+ }, 0);
2978
+ };
2979
+
2980
+ /**
2981
+ * Called by Flash to notify WebSockets events are fired.
2982
+ */
2983
+ WebSocket.__onFlashEvent = function() {
2984
+ setTimeout(function() {
2985
+ try {
2986
+ // Gets events using receiveEvents() instead of getting it from event object
2987
+ // of Flash event. This is to make sure to keep message order.
2988
+ // It seems sometimes Flash events don't arrive in the same order as they are sent.
2989
+ var events = WebSocket.__flash.receiveEvents();
2990
+ for (var i = 0; i < events.length; ++i) {
2991
+ WebSocket.__instances[events[i].webSocketId].__handleEvent(events[i]);
2992
+ }
2993
+ } catch (e) {
2994
+ console.error(e);
2995
+ }
2996
+ }, 0);
2997
+ return true;
2998
+ };
2999
+
3000
+ // Called by Flash.
3001
+ WebSocket.__log = function(message) {
3002
+ console.log(decodeURIComponent(message));
3003
+ };
3004
+
3005
+ // Called by Flash.
3006
+ WebSocket.__error = function(message) {
3007
+ console.error(decodeURIComponent(message));
3008
+ };
3009
+
3010
+ WebSocket.__addTask = function(task) {
3011
+ if (WebSocket.__flash) {
3012
+ task();
3013
+ } else {
3014
+ WebSocket.__tasks.push(task);
3015
+ }
3016
+ };
3017
+
3018
+ /**
3019
+ * Test if the browser is running flash lite.
3020
+ * @return {boolean} True if flash lite is running, false otherwise.
3021
+ */
3022
+ WebSocket.__isFlashLite = function() {
3023
+ if (!window.navigator || !window.navigator.mimeTypes) {
3024
+ return false;
3025
+ }
3026
+ var mimeType = window.navigator.mimeTypes["application/x-shockwave-flash"];
3027
+ if (!mimeType || !mimeType.enabledPlugin || !mimeType.enabledPlugin.filename) {
3028
+ return false;
3029
+ }
3030
+ return mimeType.enabledPlugin.filename.match(/flashlite/i) ? true : false;
3031
+ };
3032
+
3033
+ if (!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION) {
3034
+ if (window.addEventListener) {
3035
+ window.addEventListener("load", function(){
3036
+ WebSocket.__initialize();
3037
+ }, false);
3038
+ } else {
3039
+ window.attachEvent("onload", function(){
3040
+ WebSocket.__initialize();
3041
+ });
3042
+ }
3043
+ }
3044
+
3045
+ })();
3046
+
2501
3047
  /**
2502
3048
  * socket.io
2503
3049
  * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
@@ -2714,6 +3260,179 @@ var io = ('undefined' === typeof module ? {} : module.exports);
2714
3260
  , 'undefined' != typeof io ? io : module.parent.exports
2715
3261
  , this
2716
3262
  );
3263
+ /**
3264
+ * socket.io
3265
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
3266
+ * MIT Licensed
3267
+ */
3268
+
3269
+ (function (exports, io) {
3270
+
3271
+ /**
3272
+ * Expose constructor.
3273
+ */
3274
+
3275
+ exports.htmlfile = HTMLFile;
3276
+
3277
+ /**
3278
+ * The HTMLFile transport creates a `forever iframe` based transport
3279
+ * for Internet Explorer. Regular forever iframe implementations will
3280
+ * continuously trigger the browsers buzy indicators. If the forever iframe
3281
+ * is created inside a `htmlfile` these indicators will not be trigged.
3282
+ *
3283
+ * @constructor
3284
+ * @extends {io.Transport.XHR}
3285
+ * @api public
3286
+ */
3287
+
3288
+ function HTMLFile (socket) {
3289
+ io.Transport.XHR.apply(this, arguments);
3290
+ };
3291
+
3292
+ /**
3293
+ * Inherits from XHR transport.
3294
+ */
3295
+
3296
+ io.util.inherit(HTMLFile, io.Transport.XHR);
3297
+
3298
+ /**
3299
+ * Transport name
3300
+ *
3301
+ * @api public
3302
+ */
3303
+
3304
+ HTMLFile.prototype.name = 'htmlfile';
3305
+
3306
+ /**
3307
+ * Creates a new Ac...eX `htmlfile` with a forever loading iframe
3308
+ * that can be used to listen to messages. Inside the generated
3309
+ * `htmlfile` a reference will be made to the HTMLFile transport.
3310
+ *
3311
+ * @api private
3312
+ */
3313
+
3314
+ HTMLFile.prototype.get = function () {
3315
+ this.doc = new window[(['Active'].concat('Object').join('X'))]('htmlfile');
3316
+ this.doc.open();
3317
+ this.doc.write('<html></html>');
3318
+ this.doc.close();
3319
+ this.doc.parentWindow.s = this;
3320
+
3321
+ var iframeC = this.doc.createElement('div');
3322
+ iframeC.className = 'socketio';
3323
+
3324
+ this.doc.body.appendChild(iframeC);
3325
+ this.iframe = this.doc.createElement('iframe');
3326
+
3327
+ iframeC.appendChild(this.iframe);
3328
+
3329
+ var self = this
3330
+ , query = io.util.query(this.socket.options.query, 't='+ +new Date);
3331
+
3332
+ this.iframe.src = this.prepareUrl() + query;
3333
+
3334
+ io.util.on(window, 'unload', function () {
3335
+ self.destroy();
3336
+ });
3337
+ };
3338
+
3339
+ /**
3340
+ * The Socket.IO server will write script tags inside the forever
3341
+ * iframe, this function will be used as callback for the incoming
3342
+ * information.
3343
+ *
3344
+ * @param {String} data The message
3345
+ * @param {document} doc Reference to the context
3346
+ * @api private
3347
+ */
3348
+
3349
+ HTMLFile.prototype._ = function (data, doc) {
3350
+ // unescape all forward slashes. see GH-1251
3351
+ data = data.replace(/\\\//g, '/');
3352
+ this.onData(data);
3353
+ try {
3354
+ var script = doc.getElementsByTagName('script')[0];
3355
+ script.parentNode.removeChild(script);
3356
+ } catch (e) { }
3357
+ };
3358
+
3359
+ /**
3360
+ * Destroy the established connection, iframe and `htmlfile`.
3361
+ * And calls the `CollectGarbage` function of Internet Explorer
3362
+ * to release the memory.
3363
+ *
3364
+ * @api private
3365
+ */
3366
+
3367
+ HTMLFile.prototype.destroy = function () {
3368
+ if (this.iframe){
3369
+ try {
3370
+ this.iframe.src = 'about:blank';
3371
+ } catch(e){}
3372
+
3373
+ this.doc = null;
3374
+ this.iframe.parentNode.removeChild(this.iframe);
3375
+ this.iframe = null;
3376
+
3377
+ CollectGarbage();
3378
+ }
3379
+ };
3380
+
3381
+ /**
3382
+ * Disconnects the established connection.
3383
+ *
3384
+ * @returns {Transport} Chaining.
3385
+ * @api public
3386
+ */
3387
+
3388
+ HTMLFile.prototype.close = function () {
3389
+ this.destroy();
3390
+ return io.Transport.XHR.prototype.close.call(this);
3391
+ };
3392
+
3393
+ /**
3394
+ * Checks if the browser supports this transport. The browser
3395
+ * must have an `Ac...eXObject` implementation.
3396
+ *
3397
+ * @return {Boolean}
3398
+ * @api public
3399
+ */
3400
+
3401
+ HTMLFile.check = function (socket) {
3402
+ if (typeof window != "undefined" && (['Active'].concat('Object').join('X')) in window){
3403
+ try {
3404
+ var a = new window[(['Active'].concat('Object').join('X'))]('htmlfile');
3405
+ return a && io.Transport.XHR.check(socket);
3406
+ } catch(e){}
3407
+ }
3408
+ return false;
3409
+ };
3410
+
3411
+ /**
3412
+ * Check if cross domain requests are supported.
3413
+ *
3414
+ * @returns {Boolean}
3415
+ * @api public
3416
+ */
3417
+
3418
+ HTMLFile.xdomainCheck = function () {
3419
+ // we can probably do handling for sub-domains, we should
3420
+ // test that it's cross domain but a subdomain here
3421
+ return false;
3422
+ };
3423
+
3424
+ /**
3425
+ * Add the transport to your public io.transports array.
3426
+ *
3427
+ * @api private
3428
+ */
3429
+
3430
+ io.transports.push('htmlfile');
3431
+
3432
+ })(
3433
+ 'undefined' != typeof io ? io.Transport : module.exports
3434
+ , 'undefined' != typeof io ? io : module.parent.exports
3435
+ );
2717
3436
 
2718
3437
  /**
2719
3438
  * socket.io
@@ -2892,6 +3611,262 @@ var io = ('undefined' === typeof module ? {} : module.exports);
2892
3611
  , this
2893
3612
  );
2894
3613
 
3614
+ /**
3615
+ * socket.io
3616
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
3617
+ * MIT Licensed
3618
+ */
3619
+
3620
+ (function (exports, io, global) {
3621
+ /**
3622
+ * There is a way to hide the loading indicator in Firefox. If you create and
3623
+ * remove a iframe it will stop showing the current loading indicator.
3624
+ * Unfortunately we can't feature detect that and UA sniffing is evil.
3625
+ *
3626
+ * @api private
3627
+ */
3628
+
3629
+ var indicator = global.document && "MozAppearance" in
3630
+ global.document.documentElement.style;
3631
+
3632
+ /**
3633
+ * Expose constructor.
3634
+ */
3635
+
3636
+ exports['jsonp-polling'] = JSONPPolling;
3637
+
3638
+ /**
3639
+ * The JSONP transport creates an persistent connection by dynamically
3640
+ * inserting a script tag in the page. This script tag will receive the
3641
+ * information of the Socket.IO server. When new information is received
3642
+ * it creates a new script tag for the new data stream.
3643
+ *
3644
+ * @constructor
3645
+ * @extends {io.Transport.xhr-polling}
3646
+ * @api public
3647
+ */
3648
+
3649
+ function JSONPPolling (socket) {
3650
+ io.Transport['xhr-polling'].apply(this, arguments);
3651
+
3652
+ this.index = io.j.length;
3653
+
3654
+ var self = this;
3655
+
3656
+ io.j.push(function (msg) {
3657
+ self._(msg);
3658
+ });
3659
+ };
3660
+
3661
+ /**
3662
+ * Inherits from XHR polling transport.
3663
+ */
3664
+
3665
+ io.util.inherit(JSONPPolling, io.Transport['xhr-polling']);
3666
+
3667
+ /**
3668
+ * Transport name
3669
+ *
3670
+ * @api public
3671
+ */
3672
+
3673
+ JSONPPolling.prototype.name = 'jsonp-polling';
3674
+
3675
+ /**
3676
+ * Posts a encoded message to the Socket.IO server using an iframe.
3677
+ * The iframe is used because script tags can create POST based requests.
3678
+ * The iframe is positioned outside of the view so the user does not
3679
+ * notice it's existence.
3680
+ *
3681
+ * @param {String} data A encoded message.
3682
+ * @api private
3683
+ */
3684
+
3685
+ JSONPPolling.prototype.post = function (data) {
3686
+ var self = this
3687
+ , query = io.util.query(
3688
+ this.socket.options.query
3689
+ , 't='+ (+new Date) + '&i=' + this.index
3690
+ );
3691
+
3692
+ if (!this.form) {
3693
+ var form = document.createElement('form')
3694
+ , area = document.createElement('textarea')
3695
+ , id = this.iframeId = 'socketio_iframe_' + this.index
3696
+ , iframe;
3697
+
3698
+ form.className = 'socketio';
3699
+ form.style.position = 'absolute';
3700
+ form.style.top = '0px';
3701
+ form.style.left = '0px';
3702
+ form.style.display = 'none';
3703
+ form.target = id;
3704
+ form.method = 'POST';
3705
+ form.setAttribute('accept-charset', 'utf-8');
3706
+ area.name = 'd';
3707
+ form.appendChild(area);
3708
+ document.body.appendChild(form);
3709
+
3710
+ this.form = form;
3711
+ this.area = area;
3712
+ }
3713
+
3714
+ this.form.action = this.prepareUrl() + query;
3715
+
3716
+ function complete () {
3717
+ initIframe();
3718
+ self.socket.setBuffer(false);
3719
+ };
3720
+
3721
+ function initIframe () {
3722
+ if (self.iframe) {
3723
+ self.form.removeChild(self.iframe);
3724
+ }
3725
+
3726
+ try {
3727
+ // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
3728
+ iframe = document.createElement('<iframe name="'+ self.iframeId +'">');
3729
+ } catch (e) {
3730
+ iframe = document.createElement('iframe');
3731
+ iframe.name = self.iframeId;
3732
+ }
3733
+
3734
+ iframe.id = self.iframeId;
3735
+
3736
+ self.form.appendChild(iframe);
3737
+ self.iframe = iframe;
3738
+ };
3739
+
3740
+ initIframe();
3741
+
3742
+ // we temporarily stringify until we figure out how to prevent
3743
+ // browsers from turning `\n` into `\r\n` in form inputs
3744
+ this.area.value = io.JSON.stringify(data);
3745
+
3746
+ try {
3747
+ this.form.submit();
3748
+ } catch(e) {}
3749
+
3750
+ if (this.iframe.attachEvent) {
3751
+ iframe.onreadystatechange = function () {
3752
+ if (self.iframe.readyState == 'complete') {
3753
+ complete();
3754
+ }
3755
+ };
3756
+ } else {
3757
+ this.iframe.onload = complete;
3758
+ }
3759
+
3760
+ this.socket.setBuffer(true);
3761
+ };
3762
+
3763
+ /**
3764
+ * Creates a new JSONP poll that can be used to listen
3765
+ * for messages from the Socket.IO server.
3766
+ *
3767
+ * @api private
3768
+ */
3769
+
3770
+ JSONPPolling.prototype.get = function () {
3771
+ var self = this
3772
+ , script = document.createElement('script')
3773
+ , query = io.util.query(
3774
+ this.socket.options.query
3775
+ , 't='+ (+new Date) + '&i=' + this.index
3776
+ );
3777
+
3778
+ if (this.script) {
3779
+ this.script.parentNode.removeChild(this.script);
3780
+ this.script = null;
3781
+ }
3782
+
3783
+ script.async = true;
3784
+ script.src = this.prepareUrl() + query;
3785
+ script.onerror = function () {
3786
+ self.onClose();
3787
+ };
3788
+
3789
+ var insertAt = document.getElementsByTagName('script')[0];
3790
+ insertAt.parentNode.insertBefore(script, insertAt);
3791
+ this.script = script;
3792
+
3793
+ if (indicator) {
3794
+ setTimeout(function () {
3795
+ var iframe = document.createElement('iframe');
3796
+ document.body.appendChild(iframe);
3797
+ document.body.removeChild(iframe);
3798
+ }, 100);
3799
+ }
3800
+ };
3801
+
3802
+ /**
3803
+ * Callback function for the incoming message stream from the Socket.IO server.
3804
+ *
3805
+ * @param {String} data The message
3806
+ * @api private
3807
+ */
3808
+
3809
+ JSONPPolling.prototype._ = function (msg) {
3810
+ this.onData(msg);
3811
+ if (this.isOpen) {
3812
+ this.get();
3813
+ }
3814
+ return this;
3815
+ };
3816
+
3817
+ /**
3818
+ * The indicator hack only works after onload
3819
+ *
3820
+ * @param {Socket} socket The socket instance that needs a transport
3821
+ * @param {Function} fn The callback
3822
+ * @api private
3823
+ */
3824
+
3825
+ JSONPPolling.prototype.ready = function (socket, fn) {
3826
+ var self = this;
3827
+ if (!indicator) return fn.call(this);
3828
+
3829
+ io.util.load(function () {
3830
+ fn.call(self);
3831
+ });
3832
+ };
3833
+
3834
+ /**
3835
+ * Checks if browser supports this transport.
3836
+ *
3837
+ * @return {Boolean}
3838
+ * @api public
3839
+ */
3840
+
3841
+ JSONPPolling.check = function () {
3842
+ return 'document' in global;
3843
+ };
3844
+
3845
+ /**
3846
+ * Check if cross domain requests are supported
3847
+ *
3848
+ * @returns {Boolean}
3849
+ * @api public
3850
+ */
3851
+
3852
+ JSONPPolling.xdomainCheck = function () {
3853
+ return true;
3854
+ };
3855
+
3856
+ /**
3857
+ * Add the transport to your public io.transports array.
3858
+ *
3859
+ * @api private
3860
+ */
3861
+
3862
+ io.transports.push('jsonp-polling');
3863
+
3864
+ })(
3865
+ 'undefined' != typeof io ? io.Transport : module.exports
3866
+ , 'undefined' != typeof io ? io : module.parent.exports
3867
+ , this
3868
+ );
3869
+
2895
3870
  if (typeof define === "function" && define.amd) {
2896
3871
  define([], function () { return io; });
2897
3872
  }
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socket.io-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
5
- prerelease:
4
+ version: 0.9.16
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jason Chen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
11
+ date: 2013-07-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: railties
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.1'
30
27
  description: Rails asset pipeline wrapper for socket.io
@@ -41,26 +38,25 @@ files:
41
38
  - README.md
42
39
  homepage: https://github.com/jhchen/socket.io-rails
43
40
  licenses: []
41
+ metadata: {}
44
42
  post_install_message:
45
43
  rdoc_options: []
46
44
  require_paths:
47
45
  - lib
48
46
  required_ruby_version: !ruby/object:Gem::Requirement
49
- none: false
50
47
  requirements:
51
- - - ! '>='
48
+ - - '>='
52
49
  - !ruby/object:Gem::Version
53
50
  version: '0'
54
51
  required_rubygems_version: !ruby/object:Gem::Requirement
55
- none: false
56
52
  requirements:
57
- - - ! '>='
53
+ - - '>='
58
54
  - !ruby/object:Gem::Version
59
55
  version: '0'
60
56
  requirements: []
61
57
  rubyforge_project:
62
- rubygems_version: 1.8.24
58
+ rubygems_version: 2.0.2
63
59
  signing_key:
64
- specification_version: 3
60
+ specification_version: 4
65
61
  summary: Rails asset pipeline wrapper for socket.io
66
62
  test_files: []