faye 0.8.11 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of faye might be problematic. Click here for more details.

Files changed (73) hide show
  1. data/{History.txt → CHANGELOG.md} +126 -105
  2. data/README.md +36 -0
  3. data/lib/faye-browser-min.js +2 -1
  4. data/lib/faye-browser-min.js.map +1 -8
  5. data/lib/faye-browser.js +923 -607
  6. data/lib/faye.rb +11 -5
  7. data/lib/faye/adapters/rack_adapter.rb +80 -85
  8. data/lib/faye/engines/connection.rb +7 -9
  9. data/lib/faye/engines/memory.rb +1 -0
  10. data/lib/faye/engines/proxy.rb +7 -6
  11. data/lib/faye/mixins/deferrable.rb +15 -0
  12. data/lib/faye/mixins/logging.rb +11 -22
  13. data/lib/faye/mixins/publisher.rb +9 -20
  14. data/lib/faye/protocol/channel.rb +2 -1
  15. data/lib/faye/protocol/client.rb +70 -48
  16. data/lib/faye/protocol/envelope.rb +24 -0
  17. data/lib/faye/protocol/extensible.rb +7 -4
  18. data/lib/faye/protocol/publication.rb +1 -1
  19. data/lib/faye/protocol/server.rb +8 -11
  20. data/lib/faye/protocol/socket.rb +6 -4
  21. data/lib/faye/protocol/subscription.rb +1 -1
  22. data/lib/faye/transport/http.rb +20 -27
  23. data/lib/faye/transport/local.rb +5 -5
  24. data/lib/faye/transport/transport.rb +42 -12
  25. data/lib/faye/transport/web_socket.rb +71 -38
  26. metadata +169 -137
  27. checksums.yaml +0 -7
  28. data/README.rdoc +0 -83
  29. data/spec/browser.html +0 -45
  30. data/spec/encoding_helper.rb +0 -7
  31. data/spec/install.sh +0 -78
  32. data/spec/javascript/channel_spec.js +0 -15
  33. data/spec/javascript/client_spec.js +0 -729
  34. data/spec/javascript/dispatcher_spec.js +0 -122
  35. data/spec/javascript/engine/memory_spec.js +0 -7
  36. data/spec/javascript/engine_spec.js +0 -417
  37. data/spec/javascript/faye_spec.js +0 -34
  38. data/spec/javascript/grammar_spec.js +0 -66
  39. data/spec/javascript/node_adapter_spec.js +0 -314
  40. data/spec/javascript/publisher_spec.js +0 -27
  41. data/spec/javascript/server/connect_spec.js +0 -168
  42. data/spec/javascript/server/disconnect_spec.js +0 -121
  43. data/spec/javascript/server/extensions_spec.js +0 -60
  44. data/spec/javascript/server/handshake_spec.js +0 -145
  45. data/spec/javascript/server/integration_spec.js +0 -131
  46. data/spec/javascript/server/publish_spec.js +0 -85
  47. data/spec/javascript/server/subscribe_spec.js +0 -247
  48. data/spec/javascript/server/unsubscribe_spec.js +0 -245
  49. data/spec/javascript/server_spec.js +0 -121
  50. data/spec/javascript/transport_spec.js +0 -135
  51. data/spec/node.js +0 -55
  52. data/spec/phantom.js +0 -17
  53. data/spec/ruby/channel_spec.rb +0 -17
  54. data/spec/ruby/client_spec.rb +0 -741
  55. data/spec/ruby/engine/memory_spec.rb +0 -7
  56. data/spec/ruby/engine_examples.rb +0 -427
  57. data/spec/ruby/faye_spec.rb +0 -30
  58. data/spec/ruby/grammar_spec.rb +0 -68
  59. data/spec/ruby/publisher_spec.rb +0 -27
  60. data/spec/ruby/rack_adapter_spec.rb +0 -241
  61. data/spec/ruby/server/connect_spec.rb +0 -170
  62. data/spec/ruby/server/disconnect_spec.rb +0 -120
  63. data/spec/ruby/server/extensions_spec.rb +0 -68
  64. data/spec/ruby/server/handshake_spec.rb +0 -143
  65. data/spec/ruby/server/integration_spec.rb +0 -133
  66. data/spec/ruby/server/publish_spec.rb +0 -81
  67. data/spec/ruby/server/subscribe_spec.rb +0 -247
  68. data/spec/ruby/server/unsubscribe_spec.rb +0 -247
  69. data/spec/ruby/server_spec.rb +0 -121
  70. data/spec/ruby/transport_spec.rb +0 -136
  71. data/spec/spec_helper.rb +0 -11
  72. data/spec/testswarm +0 -42
  73. data/spec/thin_proxy.rb +0 -37
@@ -1,2 +1,3 @@
1
- 'use strict';var Faye={VERSION:'0.8.11',BAYEUX_VERSION:'1.0',ID_LENGTH:160,JSONP_CALLBACK:'jsonpcallback',CONNECTION_TYPES:['long-polling','cross-origin-long-polling','callback-polling','websocket','eventsource','in-process'],MANDATORY_CONNECTION_TYPES:['long-polling','callback-polling','in-process'],ENV:(typeof global==='undefined')?window:global,extend:function(a,b,d){if(!b)return a;for(var f in b){if(!b.hasOwnProperty(f))continue;if(a.hasOwnProperty(f)&&d===false)continue;if(a[f]!==b[f])a[f]=b[f]}return a},random:function(a){a=a||this.ID_LENGTH;if(a>32){var b=Math.ceil(a/32),d='';while(b--)d+=this.random(32);var f=d.split(''),g='';while(f.length>0)g+=f.pop();return g}var h=Math.pow(2,a)-1,i=h.toString(36).length,d=Math.floor(Math.random()*h).toString(36);while(d.length<i)d='0'+d;return d},clientIdFromMessages:function(a){var b=[].concat(a)[0];return b&&b.clientId},copyObject:function(a){var b,d,f;if(a instanceof Array){b=[];d=a.length;while(d--)b[d]=Faye.copyObject(a[d]);return b}else if(typeof a==='object'){b=(a===null)?null:{};for(f in a)b[f]=Faye.copyObject(a[f]);return b}else{return a}},commonElement:function(a,b){for(var d=0,f=a.length;d<f;d++){if(this.indexOf(b,a[d])!==-1)return a[d]}return null},indexOf:function(a,b){if(a.indexOf)return a.indexOf(b);for(var d=0,f=a.length;d<f;d++){if(a[d]===b)return d}return-1},map:function(a,b,d){if(a.map)return a.map(b,d);var f=[];if(a instanceof Array){for(var g=0,h=a.length;g<h;g++){f.push(b.call(d||null,a[g],g))}}else{for(var i in a){if(!a.hasOwnProperty(i))continue;f.push(b.call(d||null,i,a[i]))}}return f},filter:function(a,b,d){var f=[];for(var g=0,h=a.length;g<h;g++){if(b.call(d||null,a[g],g))f.push(a[g])}return f},asyncEach:function(a,b,d,f){var g=a.length,h=-1,i=0,k=false;var j=function(){i-=1;h+=1;if(h===g)return d&&d.call(f);b(a[h],n)};var m=function(){if(k)return;k=true;while(i>0)j();k=false};var n=function(){i+=1;m()};n()},toJSON:function(a){if(this.stringify)return this.stringify(a,function(key,value){return(this[key]instanceof Array)?this[key]:value});return JSON.stringify(a)},logger:function(a){if(typeof console!=='undefined')console.log(a)},timestamp:function(){var b=new Date(),d=b.getFullYear(),f=b.getMonth()+1,g=b.getDate(),h=b.getHours(),i=b.getMinutes(),k=b.getSeconds();var j=function(a){return a<10?'0'+a:String(a)};return j(d)+'-'+j(f)+'-'+j(g)+' '+j(h)+':'+j(i)+':'+j(k)}};if(typeof window!=='undefined')window.Faye=Faye;Faye.Class=function(a,b){if(typeof a!=='function'){b=a;a=Object}var d=function(){if(!this.initialize)return this;return this.initialize.apply(this,arguments)||this};var f=function(){};f.prototype=a.prototype;d.prototype=new f();Faye.extend(d.prototype,b);return d};Faye.Namespace=Faye.Class({initialize:function(){this._e={}},exists:function(a){return this._e.hasOwnProperty(a)},generate:function(){var a=Faye.random();while(this._e.hasOwnProperty(a))a=Faye.random();return this._e[a]=a},release:function(a){delete this._e[a]}});Faye.Error=Faye.Class({initialize:function(a,b,d){this.code=a;this.params=Array.prototype.slice.call(b);this.message=d},toString:function(){return this.code+':'+this.params.join(',')+':'+this.message}});Faye.Error.parse=function(a){a=a||'';if(!Faye.Grammar.ERROR.test(a))return new this(null,[],a);var b=a.split(':'),d=parseInt(b[0]),f=b[1].split(','),a=b[2];return new this(d,f,a)};Faye.Error.versionMismatch=function(){return new this(300,arguments,"Version mismatch").toString()};Faye.Error.conntypeMismatch=function(){return new this(301,arguments,"Connection types not supported").toString()};Faye.Error.extMismatch=function(){return new this(302,arguments,"Extension mismatch").toString()};Faye.Error.badRequest=function(){return new this(400,arguments,"Bad request").toString()};Faye.Error.clientUnknown=function(){return new this(401,arguments,"Unknown client").toString()};Faye.Error.parameterMissing=function(){return new this(402,arguments,"Missing required parameter").toString()};Faye.Error.channelForbidden=function(){return new this(403,arguments,"Forbidden channel").toString()};Faye.Error.channelUnknown=function(){return new this(404,arguments,"Unknown channel").toString()};Faye.Error.channelInvalid=function(){return new this(405,arguments,"Invalid channel").toString()};Faye.Error.extUnknown=function(){return new this(406,arguments,"Unknown extension").toString()};Faye.Error.publishFailed=function(){return new this(407,arguments,"Failed to publish").toString()};Faye.Error.serverError=function(){return new this(500,arguments,"Internal server error").toString()};Faye.Deferrable={callback:function(a,b){if(!a)return;if(this._v==='succeeded')return a.apply(b,this._j);this._k=this._k||[];this._k.push([a,b])},timeout:function(a,b){var d=this;var f=Faye.ENV.setTimeout(function(){d.setDeferredStatus('failed',b)},a*1000);this._w=f},errback:function(a,b){if(!a)return;if(this._v==='failed')return a.apply(b,this._j);this._l=this._l||[];this._l.push([a,b])},setDeferredStatus:function(){if(this._w)Faye.ENV.clearTimeout(this._w);var a=Array.prototype.slice.call(arguments),b=a.shift(),d;this._v=b;this._j=a;if(b==='succeeded')d=this._k;else if(b==='failed')d=this._l;if(!d)return;var f;while(f=d.shift())f[0].apply(f[1],this._j)}};Faye.Publisher={countListeners:function(a){if(!this._4||!this._4[a])return 0;return this._4[a].length},bind:function(a,b,d){this._4=this._4||{};var f=this._4[a]=this._4[a]||[];f.push([b,d])},unbind:function(a,b,d){if(!this._4||!this._4[a])return;if(!b){delete this._4[a];return}var f=this._4[a],g=f.length;while(g--){if(b!==f[g][0])continue;if(d&&f[g][1]!==d)continue;f.splice(g,1)}},trigger:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();if(!this._4||!this._4[b])return;var d=this._4[b].slice(),f;for(var g=0,h=d.length;g<h;g++){f=d[g];f[0].apply(f[1],a)}}};Faye.Timeouts={addTimeout:function(a,b,d,f){this._6=this._6||{};if(this._6.hasOwnProperty(a))return;var g=this;this._6[a]=Faye.ENV.setTimeout(function(){delete g._6[a];d.call(f)},1000*b)},removeTimeout:function(a){this._6=this._6||{};var b=this._6[a];if(!b)return;clearTimeout(b);delete this._6[a]}};Faye.Logging={LOG_LEVELS:{error:3,warn:2,info:1,debug:0},logLevel:'error',log:function(a,b){if(!Faye.logger)return;var d=Faye.Logging.LOG_LEVELS;if(d[Faye.Logging.logLevel]>d[b])return;var a=Array.prototype.slice.apply(a),f=' ['+b.toUpperCase()+'] [Faye',g=this.className,h=a.shift().replace(/\?/g,function(){try{return Faye.toJSON(a.shift())}catch(e){return'[Object]'}});for(var i in Faye){if(g)continue;if(typeof Faye[i]!=='function')continue;if(this instanceof Faye[i])g=i}if(g)f+='.'+g;f+='] ';Faye.logger(Faye.timestamp()+f+h)}};(function(){for(var d in Faye.Logging.LOG_LEVELS)(function(a,b){Faye.Logging[a]=function(){this.log(arguments,a)}})(d,Faye.Logging.LOG_LEVELS[d])})();Faye.Grammar={LOWALPHA:/^[a-z]$/,UPALPHA:/^[A-Z]$/,ALPHA:/^([a-z]|[A-Z])$/,DIGIT:/^[0-9]$/,ALPHANUM:/^(([a-z]|[A-Z])|[0-9])$/,MARK:/^(\-|\_|\!|\~|\(|\)|\$|\@)$/,STRING:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,TOKEN:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,INTEGER:/^([0-9])+$/,CHANNEL_SEGMENT:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,CHANNEL_SEGMENTS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,WILD_CARD:/^\*{1,2}$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,VERSION_ELEMENT:/^(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/,CLIENT_ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ERROR_MESSAGE:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,ERROR_ARGS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*$/,ERROR_CODE:/^[0-9][0-9][0-9]$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/};Faye.Extensible={addExtension:function(a){this._7=this._7||[];this._7.push(a);if(a.added)a.added(this)},removeExtension:function(a){if(!this._7)return;var b=this._7.length;while(b--){if(this._7[b]!==a)continue;this._7.splice(b,1);if(a.removed)a.removed(this)}},pipeThroughExtensions:function(d,f,g,h){this.debug('Passing through ? extensions: ?',d,f);if(!this._7)return g.call(h,f);var i=this._7.slice();var k=function(a){if(!a)return g.call(h,a);var b=i.shift();if(!b)return g.call(h,a);if(b[d])b[d](a,k);else k(a)};k(f)}};Faye.extend(Faye.Extensible,Faye.Logging);Faye.Channel=Faye.Class({initialize:function(a){this.id=this.name=a},push:function(a){this.trigger('message',a)},isUnused:function(){return this.countListeners('message')===0}});Faye.extend(Faye.Channel.prototype,Faye.Publisher);Faye.extend(Faye.Channel,{HANDSHAKE:'/meta/handshake',CONNECT:'/meta/connect',SUBSCRIBE:'/meta/subscribe',UNSUBSCRIBE:'/meta/unsubscribe',DISCONNECT:'/meta/disconnect',META:'meta',SERVICE:'service',expand:function(a){var b=this.parse(a),d=['/**',a];var f=b.slice();f[f.length-1]='*';d.push(this.unparse(f));for(var g=1,h=b.length;g<h;g++){f=b.slice(0,g);f.push('**');d.push(this.unparse(f))}return d},isValid:function(a){return Faye.Grammar.CHANNEL_NAME.test(a)||Faye.Grammar.CHANNEL_PATTERN.test(a)},parse:function(a){if(!this.isValid(a))return null;return a.split('/').slice(1)},unparse:function(a){return'/'+a.join('/')},isMeta:function(a){var b=this.parse(a);return b?(b[0]===this.META):null},isService:function(a){var b=this.parse(a);return b?(b[0]===this.SERVICE):null},isSubscribable:function(a){if(!this.isValid(a))return null;return!this.isMeta(a)&&!this.isService(a)},Set:Faye.Class({initialize:function(){this._2={}},getKeys:function(){var a=[];for(var b in this._2)a.push(b);return a},remove:function(a){delete this._2[a]},hasSubscription:function(a){return this._2.hasOwnProperty(a)},subscribe:function(a,b,d){if(!b)return;var f;for(var g=0,h=a.length;g<h;g++){f=a[g];var i=this._2[f]=this._2[f]||new Faye.Channel(f);i.bind('message',b,d)}},unsubscribe:function(a,b,d){var f=this._2[a];if(!f)return false;f.unbind('message',b,d);if(f.isUnused()){this.remove(a);return true}else{return false}},distributeMessage:function(a){var b=Faye.Channel.expand(a.channel);for(var d=0,f=b.length;d<f;d++){var g=this._2[b[d]];if(g)g.trigger('message',a.data)}}})});Faye.Publication=Faye.Class(Faye.Deferrable);Faye.Subscription=Faye.Class({initialize:function(a,b,d,f){this._8=a;this._2=b;this._m=d;this._n=f;this._x=false},cancel:function(){if(this._x)return;this._8.unsubscribe(this._2,this._m,this._n);this._x=true},unsubscribe:function(){this.cancel()}});Faye.extend(Faye.Subscription.prototype,Faye.Deferrable);Faye.Client=Faye.Class({UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:'handshake',RETRY:'retry',NONE:'none',CONNECTION_TIMEOUT:60.0,DEFAULT_RETRY:5.0,DEFAULT_ENDPOINT:'/bayeux',INTERVAL:0.0,initialize:function(a,b){this.info('New client created for ?',a);this._f=b||{};this.endpoint=a||this.DEFAULT_ENDPOINT;this.endpoints=this._f.endpoints||{};this.transports={};this._D=Faye.CookieJar&&new Faye.CookieJar();this._y={};this._o=[];this.retry=this._f.retry||this.DEFAULT_RETRY;this._1=this.UNCONNECTED;this._2=new Faye.Channel.Set();this._g=0;this._p={};this._9={reconnect:this.RETRY,interval:1000*(this._f.interval||this.INTERVAL),timeout:1000*(this._f.timeout||this.CONNECTION_TIMEOUT)};if(Faye.Event)Faye.Event.on(Faye.ENV,'beforeunload',function(){if(Faye.indexOf(this._o,'autodisconnect')<0)this.disconnect()},this)},disable:function(a){this._o.push(a)},setHeader:function(a,b){this._y[a]=b},getClientId:function(){return this._0},getState:function(){switch(this._1){case this.UNCONNECTED:return'UNCONNECTED';case this.CONNECTING:return'CONNECTING';case this.CONNECTED:return'CONNECTED';case this.DISCONNECTED:return'DISCONNECTED'}},handshake:function(b,d){if(this._9.reconnect===this.NONE)return;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var f=this;this.info('Initiating handshake with ?',this.endpoint);this._z(Faye.MANDATORY_CONNECTION_TYPES);this._a({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:[this._5.connectionType]},function(a){if(a.successful){this._1=this.CONNECTED;this._0=a.clientId;this._z(a.supportedConnectionTypes);this.info('Handshake successful: ?',this._0);this.subscribe(this._2.getKeys(),true);if(b)b.call(d)}else{this.info('Handshake unsuccessful');Faye.ENV.setTimeout(function(){f.handshake(b,d)},this._9.interval);this._1=this.UNCONNECTED}},this)},connect:function(a,b){if(this._9.reconnect===this.NONE)return;if(this._1===this.DISCONNECTED)return;if(this._1===this.UNCONNECTED)return this.handshake(function(){this.connect(a,b)},this);this.callback(a,b);if(this._1!==this.CONNECTED)return;this.info('Calling deferred actions for ?',this._0);this.setDeferredStatus('succeeded');this.setDeferredStatus('deferred');if(this._q)return;this._q=true;this.info('Initiating connection for ?',this._0);this._a({channel:Faye.Channel.CONNECT,clientId:this._0,connectionType:this._5.connectionType},this._A,this)},disconnect:function(){if(this._1!==this.CONNECTED)return;this._1=this.DISCONNECTED;this.info('Disconnecting ?',this._0);this._a({channel:Faye.Channel.DISCONNECT,clientId:this._0},function(a){if(a.successful)this._5.close()},this);this.info('Clearing channel listeners for ?',this._0);this._2=new Faye.Channel.Set()},subscribe:function(d,f,g){if(d instanceof Array)return Faye.map(d,function(c){return this.subscribe(c,f,g)},this);var h=new Faye.Subscription(this,d,f,g),i=(f===true),k=this._2.hasSubscription(d);if(k&&!i){this._2.subscribe([d],f,g);h.setDeferredStatus('succeeded');return h}this.connect(function(){this.info('Client ? attempting to subscribe to ?',this._0,d);if(!i)this._2.subscribe([d],f,g);this._a({channel:Faye.Channel.SUBSCRIBE,clientId:this._0,subscription:d},function(a){if(!a.successful){h.setDeferredStatus('failed',Faye.Error.parse(a.error));return this._2.unsubscribe(d,f,g)}var b=[].concat(a.subscription);this.info('Subscription acknowledged for ? to ?',this._0,b);h.setDeferredStatus('succeeded')},this)},this);return h},unsubscribe:function(d,f,g){if(d instanceof Array)return Faye.map(d,function(c){return this.unsubscribe(c,f,g)},this);var h=this._2.unsubscribe(d,f,g);if(!h)return;this.connect(function(){this.info('Client ? attempting to unsubscribe from ?',this._0,d);this._a({channel:Faye.Channel.UNSUBSCRIBE,clientId:this._0,subscription:d},function(a){if(!a.successful)return;var b=[].concat(a.subscription);this.info('Unsubscription acknowledged for ? from ?',this._0,b)},this)},this)},publish:function(b,d){var f=new Faye.Publication();this.connect(function(){this.info('Client ? queueing published message to ?: ?',this._0,b,d);this._a({channel:b,data:d,clientId:this._0},function(a){if(a.successful)f.setDeferredStatus('succeeded');else f.setDeferredStatus('failed',Faye.Error.parse(a.error))},this)},this);return f},receiveMessage:function(d){this.pipeThroughExtensions('incoming',d,function(a){if(!a)return;if(a.advice)this._E(a.advice);this._F(a);if(a.successful===undefined)return;var b=this._p[a.id];if(!b)return;delete this._p[a.id];b[0].call(b[1],a)},this)},_z:function(b){Faye.Transport.get(this,b,this._o,function(a){this.debug('Selected ? transport for ?',a.connectionType,a.endpoint);if(a===this._5)return;if(this._5)this._5.close();this._5=a;this._5.cookies=this._D;this._5.headers=this._y;a.bind('down',function(){if(this._b!==undefined&&!this._b)return;this._b=false;this.trigger('transport:down')},this);a.bind('up',function(){if(this._b!==undefined&&this._b)return;this._b=true;this.trigger('transport:up')},this)},this)},_a:function(b,d,f){b.id=this._G();if(d)this._p[b.id]=[d,f];this.pipeThroughExtensions('outgoing',b,function(a){if(!a)return;this._5.send(a,this._9.timeout/1000)},this)},_G:function(){this._g+=1;if(this._g>=Math.pow(2,32))this._g=0;return this._g.toString(36)},_E:function(a){Faye.extend(this._9,a);if(this._9.reconnect===this.HANDSHAKE&&this._1!==this.DISCONNECTED){this._1=this.UNCONNECTED;this._0=null;this._A()}},_F:function(a){if(!a.channel||a.data===undefined)return;this.info('Client ? calling listeners for ? with ?',this._0,a.channel,a.data);this._2.distributeMessage(a)},_H:function(){if(!this._q)return;this._q=null;this.info('Closed connection for ?',this._0)},_A:function(){this._H();var a=this;Faye.ENV.setTimeout(function(){a.connect()},this._9.interval)}});Faye.extend(Faye.Client.prototype,Faye.Deferrable);Faye.extend(Faye.Client.prototype,Faye.Publisher);Faye.extend(Faye.Client.prototype,Faye.Logging);Faye.extend(Faye.Client.prototype,Faye.Extensible);Faye.Transport=Faye.extend(Faye.Class({MAX_DELAY:0.0,batching:true,initialize:function(a,b){this._8=a;this.endpoint=b;this._c=[]},close:function(){},send:function(a,b){this.debug('Client ? sending message to ?: ?',this._8._0,this.endpoint,a);if(!this.batching)return this.request([a],b);this._c.push(a);this._I=b;if(a.channel===Faye.Channel.HANDSHAKE)return this.addTimeout('publish',0.01,this.flush,this);if(a.channel===Faye.Channel.CONNECT)this._r=a;if(this.shouldFlush&&this.shouldFlush(this._c))return this.flush();this.addTimeout('publish',this.MAX_DELAY,this.flush,this)},flush:function(){this.removeTimeout('publish');if(this._c.length>1&&this._r)this._r.advice={timeout:0};this.request(this._c,this._I);this._r=null;this._c=[]},receive:function(a){this.debug('Client ? received from ?: ?',this._8._0,this.endpoint,a);for(var b=0,d=a.length;b<d;b++){this._8.receiveMessage(a[b])}},retry:function(a,b){var d=false,f=this._8.retry*1000,g=this;return function(){if(d)return;d=true;Faye.ENV.setTimeout(function(){g.request(a,b)},f)}}}),{MAX_URL_LENGTH:2048,get:function(k,j,m,n,o){var l=k.endpoint;Faye.asyncEach(this._B,function(d,f){var g=d[0],h=d[1],i=k.endpoints[g]||l;if(Faye.indexOf(m,g)>=0)return f();if(Faye.indexOf(j,g)<0){h.isUsable(k,i,function(){});return f()}h.isUsable(k,i,function(a){if(!a)return f();var b=h.hasOwnProperty('create')?h.create(k,i):new h(k,i);n.call(o,b)})},function(){throw new Error('Could not find a usable connection type for '+l);})},register:function(a,b){this._B.push([a,b]);b.prototype.connectionType=a},_B:[]});Faye.extend(Faye.Transport.prototype,Faye.Logging);Faye.extend(Faye.Transport.prototype,Faye.Publisher);Faye.extend(Faye.Transport.prototype,Faye.Timeouts);Faye.Event={_h:[],on:function(a,b,d,f){var g=function(){d.call(f)};if(a.addEventListener)a.addEventListener(b,g,false);else a.attachEvent('on'+b,g);this._h.push({_i:a,_s:b,_m:d,_n:f,_C:g})},detach:function(a,b,d,f){var g=this._h.length,h;while(g--){h=this._h[g];if((a&&a!==h._i)||(b&&b!==h._s)||(d&&d!==h._m)||(f&&f!==h._n))continue;if(h._i.removeEventListener)h._i.removeEventListener(h._s,h._C,false);else h._i.detachEvent('on'+h._s,h._C);this._h.splice(g,1);h=null}}};Faye.Event.on(Faye.ENV,'unload',Faye.Event.detach,Faye.Event);Faye.URI=Faye.extend(Faye.Class({queryString:function(){var a=[];for(var b in this.params){if(!this.params.hasOwnProperty(b))continue;a.push(encodeURIComponent(b)+'='+encodeURIComponent(this.params[b]))}return a.join('&')},isSameOrigin:function(){var a=Faye.URI.parse(Faye.ENV.location.href,false);var b=(a.hostname!==this.hostname)||(a.port!==this.port)||(a.protocol!==this.protocol);return!b},toURL:function(){var a=this.queryString();return this.protocol+'//'+this.hostname+(this.port?':'+this.port:'')+this.pathname+(a?'?'+a:'')+this.hash}}),{parse:function(g,h){if(typeof g!=='string')return g;var i=new this(),k;var j=function(b,d,f){g=g.replace(d,function(a){i[b]=a;return''});if(i[b]===undefined)i[b]=f?Faye.ENV.location[b]:''};j('protocol',/^https?\:/,true);j('host',/^\/\/[^\/]+/,true);if(!/^\//.test(g))g=Faye.ENV.location.pathname.replace(/[^\/]*$/,'')+g;j('pathname',/^\/[^\?#]*/);j('search',/^\?[^#]*/);j('hash',/^#.*/);if(/^\/\//.test(i.host)){i.host=i.host.substr(2);k=i.host.split(':');i.hostname=k[0];i.port=k[1]||''}else{i.hostname=Faye.ENV.location.hostname;i.port=Faye.ENV.location.port}if(h===false){i.params={}}else{var m=i.search.replace(/^\?/,''),n=m?m.split('&'):[],o=n.length,l={};while(o--){k=n[o].split('=');l[decodeURIComponent(k[0]||'')]=decodeURIComponent(k[1]||'')}if(typeof h==='object')Faye.extend(l,h);i.params=l}return i}});if(!this.JSON){JSON={}}(function(){function m(a){return a<10?'0'+a:a}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(a){return this.getUTCFullYear()+'-'+m(this.getUTCMonth()+1)+'-'+m(this.getUTCDate())+'T'+m(this.getUTCHours())+':'+m(this.getUTCMinutes())+':'+m(this.getUTCSeconds())+'Z'};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()}}var n=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,l,q,t={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},p;function s(d){o.lastIndex=0;return o.test(d)?'"'+d.replace(o,function(a){var b=t[a];return typeof b==='string'?b:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+d+'"'}function r(a,b){var d,f,g,h,i=l,k,j=b[a];if(j&&typeof j==='object'&&typeof j.toJSON==='function'){j=j.toJSON(a)}if(typeof p==='function'){j=p.call(b,a,j)}switch(typeof j){case'string':return s(j);case'number':return isFinite(j)?String(j):'null';case'boolean':case'null':return String(j);case'object':if(!j){return'null'}l+=q;k=[];if(Object.prototype.toString.apply(j)==='[object Array]'){h=j.length;for(d=0;d<h;d+=1){k[d]=r(d,j)||'null'}g=k.length===0?'[]':l?'[\n'+l+k.join(',\n'+l)+'\n'+i+']':'['+k.join(',')+']';l=i;return g}if(p&&typeof p==='object'){h=p.length;for(d=0;d<h;d+=1){f=p[d];if(typeof f==='string'){g=r(f,j);if(g){k.push(s(f)+(l?': ':':')+g)}}}}else{for(f in j){if(Object.hasOwnProperty.call(j,f)){g=r(f,j);if(g){k.push(s(f)+(l?': ':':')+g)}}}}g=k.length===0?'{}':l?'{\n'+l+k.join(',\n'+l)+'\n'+i+'}':'{'+k.join(',')+'}';l=i;return g}}Faye.stringify=function(a,b,d){var f;l='';q='';if(typeof d==='number'){for(f=0;f<d;f+=1){q+=' '}}else if(typeof d==='string'){q=d}p=b;if(b&&typeof b!=='function'&&(typeof b!=='object'||typeof b.length!=='number')){throw new Error('JSON.stringify');}return r('',{'':a})};if(typeof JSON.stringify!=='function'){JSON.stringify=Faye.stringify}if(typeof JSON.parse!=='function'){JSON.parse=function(h,i){var k;function j(a,b){var d,f,g=a[b];if(g&&typeof g==='object'){for(d in g){if(Object.hasOwnProperty.call(g,d)){f=j(g,d);if(f!==undefined){g[d]=f}else{delete g[d]}}}}return i.call(a,b,g)}n.lastIndex=0;if(n.test(h)){h=h.replace(n,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(h.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){k=eval('('+h+')');return typeof i==='function'?j({'':k},''):k}throw new SyntaxError('JSON.parse');}}}());Faye.Transport.WebSocket=Faye.extend(Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:false,isUsable:function(a,b){this.callback(function(){a.call(b,true)});this.errback(function(){a.call(b,false)});this.connect()},request:function(b,d){if(b.length===0)return;this._d=this._d||{};for(var f=0,g=b.length;f<g;f++){this._d[b[f].id]=b[f]}this.callback(function(a){a.send(Faye.toJSON(b))});this.connect()},close:function(){if(!this._3)return;this._3.onclose=this._3.onerror=null;this._3.close();delete this._3;this.setDeferredStatus('deferred');this._1=this.UNCONNECTED},connect:function(){if(Faye.Transport.WebSocket._J)return;this._1=this._1||this.UNCONNECTED;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var g=Faye.Transport.WebSocket.getClass();if(!g)return this.setDeferredStatus('failed');this._3=new g(Faye.Transport.WebSocket.getSocketUrl(this.endpoint));var h=this;this._3.onopen=function(){h._1=h.CONNECTED;h._t=true;h.setDeferredStatus('succeeded',h._3);h.trigger('up')};this._3.onmessage=function(a){var b=JSON.parse(a.data);if(!b)return;b=[].concat(b);for(var d=0,f=b.length;d<f;d++){delete h._d[b[d].id]}h.receive(b)};this._3.onclose=this._3.onerror=function(){var a=(h._1===h.CONNECTED);h.setDeferredStatus('deferred');h._1=h.UNCONNECTED;h.close();if(a)return h.resend();if(!h._t)return h.setDeferredStatus('failed');var b=h._8.retry*1000;Faye.ENV.setTimeout(function(){h.connect()},b);h.trigger('down')}},resend:function(){if(!this._d)return;var d=Faye.map(this._d,function(a,b){return b});this.request(d)}}),{getSocketUrl:function(a){if(Faye.URI)a=Faye.URI.parse(a).toURL();return a.replace(/^http(s?):/ig,'ws$1:')},getClass:function(){return(Faye.WebSocket&&Faye.WebSocket.Client)||Faye.ENV.WebSocket||Faye.ENV.MozWebSocket},isUsable:function(a,b,d,f){this.create(a,b).isUsable(d,f)},create:function(a,b){var d=a.transports.websocket=a.transports.websocket||{};d[b]=d[b]||new this(a,b);return d[b]}});Faye.extend(Faye.Transport.WebSocket.prototype,Faye.Deferrable);Faye.Transport.register('websocket',Faye.Transport.WebSocket);if(Faye.Event)Faye.Event.on(Faye.ENV,'beforeunload',function(){Faye.Transport.WebSocket._J=true});Faye.Transport.EventSource=Faye.extend(Faye.Class(Faye.Transport,{initialize:function(b,d){Faye.Transport.prototype.initialize.call(this,b,d);if(!Faye.ENV.EventSource)return this.setDeferredStatus('failed');this._K=new Faye.Transport.XHR(b,d);var f=new EventSource(d+'/'+b.getClientId()),g=this;f.onopen=function(){g._t=true;g.setDeferredStatus('succeeded');g.trigger('up')};f.onerror=function(){if(g._t){g.trigger('down')}else{g.setDeferredStatus('failed');f.close()}};f.onmessage=function(a){g.receive(JSON.parse(a.data));g.trigger('up')};this._3=f},isUsable:function(a,b){this.callback(function(){a.call(b,true)});this.errback(function(){a.call(b,false)})},request:function(a,b){this._K.request(a,b)},close:function(){if(!this._3)return;this._3.onerror=null;this._3.close();delete this._3}}),{isUsable:function(b,d,f,g){var h=b.getClientId();if(!h)return f.call(g,false);Faye.Transport.XHR.isUsable(b,d,function(a){if(!a)return f.call(g,false);this.create(b,d).isUsable(f,g)},this)},create:function(a,b){var d=a.transports.eventsource=a.transports.eventsource||{},f=a.getClientId(),b=b+'/'+(f||'');d[b]=d[b]||new this(a,b);return d[b]}});Faye.extend(Faye.Transport.EventSource.prototype,Faye.Deferrable);Faye.Transport.register('eventsource',Faye.Transport.EventSource);Faye.Transport.XHR=Faye.extend(Faye.Class(Faye.Transport,{request:function(f,g){var h=this.retry(f,g),i=Faye.URI.parse(this.endpoint).pathname,k=this,j=Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();j.open('POST',i,true);j.setRequestHeader('Content-Type','application/json');j.setRequestHeader('Pragma','no-cache');j.setRequestHeader('X-Requested-With','XMLHttpRequest');var m=this.headers;for(var n in m){if(!m.hasOwnProperty(n))continue;j.setRequestHeader(n,m[n])}var o=function(){j.abort()};Faye.Event.on(Faye.ENV,'beforeunload',o);var l=function(){Faye.Event.detach(Faye.ENV,'beforeunload',o);j.onreadystatechange=function(){};j=null};j.onreadystatechange=function(){if(j.readyState!==4)return;var a=null,b=j.status,d=((b>=200&&b<300)||b===304||b===1223);if(!d){l();h();return k.trigger('down')}try{a=JSON.parse(j.responseText)}catch(e){}l();if(a){k.receive(a);k.trigger('up')}else{h();k.trigger('down')}};j.send(Faye.toJSON(f))}}),{isUsable:function(a,b,d,f){d.call(f,Faye.URI.parse(b).isSameOrigin())}});Faye.Transport.register('long-polling',Faye.Transport.XHR);Faye.Transport.CORS=Faye.extend(Faye.Class(Faye.Transport,{request:function(b,d){var f=Faye.ENV.XDomainRequest?XDomainRequest:XMLHttpRequest,g=new f(),h=this.retry(b,d),i=this;g.open('POST',this.endpoint,true);if(g.setRequestHeader)g.setRequestHeader('Pragma','no-cache');var k=function(){if(!g)return false;g.onload=g.onerror=g.ontimeout=g.onprogress=null;g=null;Faye.ENV.clearTimeout(m);return true};g.onload=function(){var a=null;try{a=JSON.parse(g.responseText)}catch(e){}k();if(a){i.receive(a);i.trigger('up')}else{h();i.trigger('down')}};var j=function(){k();h();i.trigger('down')};var m=Faye.ENV.setTimeout(j,1.5*1000*d);g.onerror=j;g.ontimeout=j;g.onprogress=function(){};g.send('message='+encodeURIComponent(Faye.toJSON(b)))}}),{isUsable:function(a,b,d,f){if(Faye.URI.parse(b).isSameOrigin())return d.call(f,false);if(Faye.ENV.XDomainRequest)return d.call(f,Faye.URI.parse(b).protocol===Faye.URI.parse(Faye.ENV.location).protocol);if(Faye.ENV.XMLHttpRequest){var g=new Faye.ENV.XMLHttpRequest();return d.call(f,g.withCredentials!==undefined)}return d.call(f,false)}});Faye.Transport.register('cross-origin-long-polling',Faye.Transport.CORS);Faye.Transport.JSONP=Faye.extend(Faye.Class(Faye.Transport,{shouldFlush:function(a){var b={message:Faye.toJSON(a),jsonp:'__jsonp'+Faye.Transport.JSONP._u+'__'};var d=Faye.URI.parse(this.endpoint,b).toURL();return d.length>=Faye.Transport.MAX_URL_LENGTH},request:function(b,d){var f={message:Faye.toJSON(b)},g=document.getElementsByTagName('head')[0],h=document.createElement('script'),i=Faye.Transport.JSONP.getCallbackName(),k=Faye.URI.parse(this.endpoint,f),j=this.retry(b,d),m=this;Faye.ENV[i]=function(a){o();m.receive(a);m.trigger('up')};var n=Faye.ENV.setTimeout(function(){o();j();m.trigger('down')},1.5*1000*d);var o=function(){if(!Faye.ENV[i])return false;Faye.ENV[i]=undefined;try{delete Faye.ENV[i]}catch(e){}Faye.ENV.clearTimeout(n);h.parentNode.removeChild(h);return true};k.params.jsonp=i;h.type='text/javascript';h.src=k.toURL();g.appendChild(h)}}),{_u:0,getCallbackName:function(){this._u+=1;return'__jsonp'+this._u+'__'},isUsable:function(a,b,d,f){d.call(f,true)}});Faye.Transport.register('callback-polling',Faye.Transport.JSONP);
1
+ !function(){"use strict";var Faye={VERSION:"1.0.0",BAYEUX_VERSION:"1.0",ID_LENGTH:160,JSONP_CALLBACK:"jsonpcallback",CONNECTION_TYPES:["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],MANDATORY_CONNECTION_TYPES:["long-polling","callback-polling","in-process"],ENV:"undefined"!=typeof window?window:global,extend:function(e,t,n){if(!t)return e;for(var i in t)t.hasOwnProperty(i)&&(e.hasOwnProperty(i)&&n===!1||e[i]!==t[i]&&(e[i]=t[i]));return e},random:function(e){return e=e||this.ID_LENGTH,csprng(e,36)},clientIdFromMessages:function(e){var t=this.filter([].concat(e),function(e){return"/meta/connect"===e.channel});return t[0]&&t[0].clientId},copyObject:function(e){var t,n,i;if(e instanceof Array){for(t=[],n=e.length;n--;)t[n]=Faye.copyObject(e[n]);return t}if("object"==typeof e){t=null===e?null:{};for(i in e)t[i]=Faye.copyObject(e[i]);return t}return e},commonElement:function(e,t){for(var n=0,i=e.length;i>n;n++)if(-1!==this.indexOf(t,e[n]))return e[n];return null},indexOf:function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,i=e.length;i>n;n++)if(e[n]===t)return n;return-1},map:function(e,t,n){if(e.map)return e.map(t,n);var i=[];if(e instanceof Array)for(var s=0,r=e.length;r>s;s++)i.push(t.call(n||null,e[s],s));else for(var o in e)e.hasOwnProperty(o)&&i.push(t.call(n||null,o,e[o]));return i},filter:function(e,t,n){if(e.filter)return e.filter(t,n);for(var i=[],s=0,r=e.length;r>s;s++)t.call(n||null,e[s],s)&&i.push(e[s]);return i},asyncEach:function(e,t,n,i){var s=e.length,r=-1,o=0,a=!1,c=function(){return o-=1,r+=1,r===s?n&&n.call(i):(t(e[r],h),void 0)},u=function(){if(!a){for(a=!0;o>0;)c();a=!1}},h=function(){o+=1,u()};h()},toJSON:function(e){return this.stringify?this.stringify(e,function(e,t){return this[e]instanceof Array?this[e]:t}):JSON.stringify(e)}};"undefined"!=typeof module?module.exports=Faye:"undefined"!=typeof window&&(window.Faye=Faye),Faye.Class=function(e,t){"function"!=typeof e&&(t=e,e=Object);var n=function(){return this.initialize?this.initialize.apply(this,arguments)||this:this},i=function(){};return i.prototype=e.prototype,n.prototype=new i,Faye.extend(n.prototype,t),n},function(){function e(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(t===e[n])return n;return-1}var t=Faye.EventEmitter=function(){},n="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};t.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||n(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var i=Array.prototype.slice.call(arguments,1);t.apply(this,i)}return!0}if(n(t)){for(var i=Array.prototype.slice.call(arguments,1),s=t.slice(),r=0,o=s.length;o>r;r++)s[r].apply(this,i);return!0}return!1},t.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");return this._events||(this._events={}),this.emit("newListener",e,t),this._events[e]?n(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){var n=this;return n.on(e,function i(){n.removeListener(e,i),t.apply(this,arguments)}),this},t.prototype.removeListener=function(t,i){if("function"!=typeof i)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var s=this._events[t];if(n(s)){var r=e(s,i);if(0>r)return this;s.splice(r,1),0==s.length&&delete this._events[t]}else this._events[t]===i&&delete this._events[t];return this},t.prototype.removeAllListeners=function(e){return 0===arguments.length?(this._events={},this):(e&&this._events&&this._events[e]&&(this._events[e]=null),this)},t.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),n(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}}(),Faye.Namespace=Faye.Class({initialize:function(){this._used={}},exists:function(e){return this._used.hasOwnProperty(e)},generate:function(){for(var e=Faye.random();this._used.hasOwnProperty(e);)e=Faye.random();return this._used[e]=e},release:function(e){delete this._used[e]}}),function(){var e,t=setTimeout;e="function"==typeof setImmediate?function(e){setImmediate(e)}:"object"==typeof process&&process.nextTick?function(e){process.nextTick(e)}:function(e){t(e,0)};var n=0,i=1,s=2,r=function(e){return e},o=function(e){throw e},a=function(e){if(this._state=n,this._callbacks=[],this._errbacks=[],"function"==typeof e){var t=this;e(function(e){l(t,e)},function(e){f(t,e)})}};a.prototype.then=function(e,t){var n=this;return new a(function(i,s){var r={fulfill:i,reject:s};c(n,e,r),u(n,t,r)})};var c=function(t,s,o){"function"!=typeof s&&(s=r);var a=function(e){h(s,e,o)};t._state===n?t._callbacks.push(a):t._state===i&&e(function(){a(t._value)})},u=function(t,i,r){"function"!=typeof i&&(i=o);var a=function(e){h(i,e,r)};t._state===n?t._errbacks.push(a):t._state===s&&e(function(){a(t._reason)})},h=function(e,t,n){try{var i=e(t);i&&"function"==typeof i.then?i.then(n.fulfill,n.reject):n.fulfill(i)}catch(s){n.reject(s)}},l=a.fulfill=function(e,t){if(e._state===n){e._state=i,e._value=t,e._errbacks=[];for(var s,r=e._callbacks;s=r.shift();)s(t)}},f=a.reject=function(e,t){if(e._state===n){e._state=s,e._reason=t,e._callbacks=[];for(var i,r=e._errbacks;i=r.shift();)i(t)}};a.defer=e,a.pending=function(){var e={};return e.promise=new a(function(t,n){e.fulfill=t,e.reject=n}),e},a.fulfilled=function(e){return new a(function(t){t(e)})},a.rejected=function(e){return new a(function(t,n){n(e)})},void 0===Faye?module.exports=a:Faye.Promise=a}(),Faye.Set=Faye.Class({initialize:function(){this._index={}},add:function(e){var t=void 0!==e.id?e.id:e;return this._index.hasOwnProperty(t)?!1:(this._index[t]=e,!0)},forEach:function(e,t){for(var n in this._index)this._index.hasOwnProperty(n)&&e.call(t,this._index[n])},isEmpty:function(){for(var e in this._index)if(this._index.hasOwnProperty(e))return!1;return!0},member:function(e){for(var t in this._index)if(this._index[t]===e)return!0;return!1},remove:function(e){var t=void 0!==e.id?e.id:e,n=this._index[t];return delete this._index[t],n},toArray:function(){var e=[];return this.forEach(function(t){e.push(t)}),e}}),Faye.URI={isURI:function(e){return e&&e.protocol&&e.host&&e.path},isSameOrigin:function(e){var t=Faye.ENV.location;return e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port},parse:function(e){if("string"!=typeof e)return e;var t,n,i,s,r,o,a={},c=function(t,n){e=e.replace(n,function(e){return a[t]=e,""}),a[t]=a[t]||""};for(c("protocol",/^[a-z]+\:/i),c("host",/^\/\/[^\/\?#]+/),/^\//.test(e)||a.host||(e=Faye.ENV.location.pathname.replace(/[^\/]*$/,"")+e),c("pathname",/^[^\?#]*/),c("search",/^\?[^#]*/),c("hash",/^#.*/),a.protocol=a.protocol||Faye.ENV.location.protocol,a.host?(a.host=a.host.substr(2),t=a.host.split(":"),a.hostname=t[0],a.port=t[1]||""):(a.host=Faye.ENV.location.host,a.hostname=Faye.ENV.location.hostname,a.port=Faye.ENV.location.port),a.pathname=a.pathname||"/",a.path=a.pathname+a.search,n=a.search.replace(/^\?/,""),i=n?n.split("&"):[],o={},s=0,r=i.length;r>s;s++)t=i[s].split("="),o[decodeURIComponent(t[0]||"")]=decodeURIComponent(t[1]||"");return a.query=o,a.href=this.stringify(a),a},stringify:function(e){var t=e.protocol+"//"+e.hostname;return e.port&&(t+=":"+e.port),t+=e.pathname+this.queryString(e.query)+(e.hash||"")},queryString:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return 0===t.length?"":"?"+t.join("&")}},Faye.Error=Faye.Class({initialize:function(e,t,n){this.code=e,this.params=Array.prototype.slice.call(t),this.message=n},toString:function(){return this.code+":"+this.params.join(",")+":"+this.message}}),Faye.Error.parse=function(e){if(e=e||"",!Faye.Grammar.ERROR.test(e))return new this(null,[],e);var t=e.split(":"),n=parseInt(t[0]),i=t[1].split(","),e=t[2];return new this(n,i,e)},Faye.Error.versionMismatch=function(){return""+new this(300,arguments,"Version mismatch")},Faye.Error.conntypeMismatch=function(){return""+new this(301,arguments,"Connection types not supported")},Faye.Error.extMismatch=function(){return""+new this(302,arguments,"Extension mismatch")},Faye.Error.badRequest=function(){return""+new this(400,arguments,"Bad request")},Faye.Error.clientUnknown=function(){return""+new this(401,arguments,"Unknown client")},Faye.Error.parameterMissing=function(){return""+new this(402,arguments,"Missing required parameter")},Faye.Error.channelForbidden=function(){return""+new this(403,arguments,"Forbidden channel")},Faye.Error.channelUnknown=function(){return""+new this(404,arguments,"Unknown channel")},Faye.Error.channelInvalid=function(){return""+new this(405,arguments,"Invalid channel")},Faye.Error.extUnknown=function(){return""+new this(406,arguments,"Unknown extension")},Faye.Error.publishFailed=function(){return""+new this(407,arguments,"Failed to publish")},Faye.Error.serverError=function(){return""+new this(500,arguments,"Internal server error")},Faye.Deferrable={then:function(e,t){var n=this;return this._promise||(this._promise=new Faye.Promise(function(e,t){n._fulfill=e,n._reject=t})),0===arguments.length?this._promise:this._promise.then(e,t)},callback:function(e,t){return this.then(function(n){e.call(t,n)})},errback:function(e,t){return this.then(null,function(n){e.call(t,n)})},timeout:function(e,t){this.then();var n=this;this._timer=Faye.ENV.setTimeout(function(){n._reject(t)},1e3*e)},setDeferredStatus:function(e,t){this._timer&&Faye.ENV.clearTimeout(this._timer),this.then(),"succeeded"===e?this._fulfill(t):"failed"===e?this._reject(t):delete this._promise}},Faye.Publisher={countListeners:function(e){return this.listeners(e).length},bind:function(e,t,n){var i=Array.prototype.slice,s=function(){t.apply(n,i.call(arguments))};return this._listeners=this._listeners||[],this._listeners.push([e,t,n,s]),this.on(e,s)},unbind:function(e,t,n){this._listeners=this._listeners||[];for(var i,s=this._listeners.length;s--;)i=this._listeners[s],i[0]===e&&(!t||i[1]===t&&i[2]===n)&&(this._listeners.splice(s,1),this.removeListener(e,i[3]))}},Faye.extend(Faye.Publisher,Faye.EventEmitter.prototype),Faye.Publisher.trigger=Faye.Publisher.emit,Faye.Timeouts={addTimeout:function(e,t,n,i){if(this._timeouts=this._timeouts||{},!this._timeouts.hasOwnProperty(e)){var s=this;this._timeouts[e]=Faye.ENV.setTimeout(function(){delete s._timeouts[e],n.call(i)},1e3*t)}},removeTimeout:function(e){this._timeouts=this._timeouts||{};var t=this._timeouts[e];t&&(clearTimeout(t),delete this._timeouts[e])}},Faye.Logging={LOG_LEVELS:{fatal:4,error:3,warn:2,info:1,debug:0},writeLog:function(e,t){if(Faye.logger){var e=Array.prototype.slice.apply(e),n="[Faye",i=this.className,s=e.shift().replace(/\?/g,function(){try{return Faye.toJSON(e.shift())}catch(t){return"[Object]"}});for(var r in Faye)i||"function"==typeof Faye[r]&&this instanceof Faye[r]&&(i=r);i&&(n+="."+i),n+="] ","function"==typeof Faye.logger[t]?Faye.logger[t](n+s):"function"==typeof Faye.logger&&Faye.logger(n+s)}}},function(){for(var e in Faye.Logging.LOG_LEVELS)(function(e){Faye.Logging[e]=function(){this.writeLog(arguments,e)}})(e,Faye.Logging.LOG_LEVELS[e])}(),Faye.Grammar={CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/},Faye.Extensible={addExtension:function(e){this._extensions=this._extensions||[],this._extensions.push(e),e.added&&e.added(this)},removeExtension:function(e){if(this._extensions)for(var t=this._extensions.length;t--;)this._extensions[t]===e&&(this._extensions.splice(t,1),e.removed&&e.removed(this))},pipeThroughExtensions:function(e,t,n,i,s){if(this.debug("Passing through ? extensions: ?",e,t),!this._extensions)return i.call(s,t);var r=this._extensions.slice(),o=function(t){if(!t)return i.call(s,t);var a=r.shift();if(!a)return i.call(s,t);var c=a[e];return c?(c.length>=3?a[e](t,n,o):a[e](t,o),void 0):o(t)};o(t)}},Faye.extend(Faye.Extensible,Faye.Logging),Faye.Channel=Faye.Class({initialize:function(e){this.id=this.name=e},push:function(e){this.trigger("message",e)},isUnused:function(){return 0===this.countListeners("message")}}),Faye.extend(Faye.Channel.prototype,Faye.Publisher),Faye.extend(Faye.Channel,{HANDSHAKE:"/meta/handshake",CONNECT:"/meta/connect",SUBSCRIBE:"/meta/subscribe",UNSUBSCRIBE:"/meta/unsubscribe",DISCONNECT:"/meta/disconnect",META:"meta",SERVICE:"service",expand:function(e){var t=this.parse(e),n=["/**",e],i=t.slice();i[i.length-1]="*",n.push(this.unparse(i));for(var s=1,r=t.length;r>s;s++)i=t.slice(0,s),i.push("**"),n.push(this.unparse(i));return n},isValid:function(e){return Faye.Grammar.CHANNEL_NAME.test(e)||Faye.Grammar.CHANNEL_PATTERN.test(e)},parse:function(e){return this.isValid(e)?e.split("/").slice(1):null},unparse:function(e){return"/"+e.join("/")},isMeta:function(e){var t=this.parse(e);return t?t[0]===this.META:null},isService:function(e){var t=this.parse(e);return t?t[0]===this.SERVICE:null},isSubscribable:function(e){return this.isValid(e)?!this.isMeta(e)&&!this.isService(e):null},Set:Faye.Class({initialize:function(){this._channels={}},getKeys:function(){var e=[];for(var t in this._channels)e.push(t);return e},remove:function(e){delete this._channels[e]},hasSubscription:function(e){return this._channels.hasOwnProperty(e)},subscribe:function(e,t,n){if(t)for(var i,s=0,r=e.length;r>s;s++){i=e[s];var o=this._channels[i]=this._channels[i]||new Faye.Channel(i);o.bind("message",t,n)}},unsubscribe:function(e,t,n){var i=this._channels[e];return i?(i.unbind("message",t,n),i.isUnused()?(this.remove(e),!0):!1):!1},distributeMessage:function(e){for(var t=Faye.Channel.expand(e.channel),n=0,i=t.length;i>n;n++){var s=this._channels[t[n]];s&&s.trigger("message",e.data)}}})}),Faye.Envelope=Faye.Class({initialize:function(e,t){this.id=e.id,this.message=e,void 0!==t&&this.timeout(t/1e3,!1)}}),Faye.extend(Faye.Envelope.prototype,Faye.Deferrable),Faye.Publication=Faye.Class(Faye.Deferrable),Faye.Subscription=Faye.Class({initialize:function(e,t,n,i){this._client=e,this._channels=t,this._callback=n,this._context=i,this._cancelled=!1},cancel:function(){this._cancelled||(this._client.unsubscribe(this._channels,this._callback,this._context),this._cancelled=!0)},unsubscribe:function(){this.cancel()}}),Faye.extend(Faye.Subscription.prototype,Faye.Deferrable),Faye.Client=Faye.Class({UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:"handshake",RETRY:"retry",NONE:"none",CONNECTION_TIMEOUT:60,DEFAULT_RETRY:5,MAX_REQUEST_SIZE:2048,DEFAULT_ENDPOINT:"/bayeux",INTERVAL:0,initialize:function(e,t){this.info("New client created for ?",e),this._options=t||{},this.endpoint=Faye.URI.parse(e||this.DEFAULT_ENDPOINT),this.endpoints=this._options.endpoints||{},this.transports={},this.cookies=Faye.CookieJar&&new Faye.CookieJar,this.headers={},this.ca=this._options.ca,this._disabled=[],this._retry=this._options.retry||this.DEFAULT_RETRY;for(var n in this.endpoints)this.endpoints[n]=Faye.URI.parse(this.endpoints[n]);this.maxRequestSize=this.MAX_REQUEST_SIZE,this._state=this.UNCONNECTED,this._channels=new Faye.Channel.Set,this._messageId=0,this._responseCallbacks={},this._advice={reconnect:this.RETRY,interval:1e3*(this._options.interval||this.INTERVAL),timeout:1e3*(this._options.timeout||this.CONNECTION_TIMEOUT)},Faye.Event&&void 0!==Faye.ENV.onbeforeunload&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.indexOf(this._disabled,"autodisconnect")<0&&this.disconnect()},this)},disable:function(e){this._disabled.push(e)},setHeader:function(e,t){this.headers[e]=t},handshake:function(e,t){if(this._advice.reconnect!==this.NONE&&this._state===this.UNCONNECTED){this._state=this.CONNECTING;var n=this;this.info("Initiating handshake with ?",Faye.URI.stringify(this.endpoint)),this._selectTransport(Faye.MANDATORY_CONNECTION_TYPES),this._send({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:[this._transport.connectionType]},function(i){i.successful?(this._state=this.CONNECTED,this._clientId=i.clientId,this._selectTransport(i.supportedConnectionTypes),this.info("Handshake successful: ?",this._clientId),this.subscribe(this._channels.getKeys(),!0),e&&Faye.Promise.defer(function(){e.call(t)})):(this.info("Handshake unsuccessful"),Faye.ENV.setTimeout(function(){n.handshake(e,t)},this._advice.interval),this._state=this.UNCONNECTED)},this)}},connect:function(e,t){if(this._advice.reconnect!==this.NONE&&this._state!==this.DISCONNECTED){if(this._state===this.UNCONNECTED)return this.handshake(function(){this.connect(e,t)},this);this.callback(e,t),this._state===this.CONNECTED&&(this.info("Calling deferred actions for ?",this._clientId),this.setDeferredStatus("succeeded"),this.setDeferredStatus("unknown"),this._connectRequest||(this._connectRequest=!0,this.info("Initiating connection for ?",this._clientId),this._send({channel:Faye.Channel.CONNECT,clientId:this._clientId,connectionType:this._transport.connectionType},this._cycleConnection,this)))}},disconnect:function(){this._state===this.CONNECTED&&(this._state=this.DISCONNECTED,this.info("Disconnecting ?",this._clientId),this._send({channel:Faye.Channel.DISCONNECT,clientId:this._clientId},function(e){e.successful&&(this._transport.close(),delete this._transport)},this),this.info("Clearing channel listeners for ?",this._clientId),this._channels=new Faye.Channel.Set)},subscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.subscribe(e,t,n)},this);var i=new Faye.Subscription(this,e,t,n),s=t===!0,r=this._channels.hasSubscription(e);return r&&!s?(this._channels.subscribe([e],t,n),i.setDeferredStatus("succeeded"),i):(this.connect(function(){this.info("Client ? attempting to subscribe to ?",this._clientId,e),s||this._channels.subscribe([e],t,n),this._send({channel:Faye.Channel.SUBSCRIBE,clientId:this._clientId,subscription:e},function(s){if(!s.successful)return i.setDeferredStatus("failed",Faye.Error.parse(s.error)),this._channels.unsubscribe(e,t,n);var r=[].concat(s.subscription);this.info("Subscription acknowledged for ? to ?",this._clientId,r),i.setDeferredStatus("succeeded")},this)},this),i)},unsubscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.unsubscribe(e,t,n)},this);var i=this._channels.unsubscribe(e,t,n);i&&this.connect(function(){this.info("Client ? attempting to unsubscribe from ?",this._clientId,e),this._send({channel:Faye.Channel.UNSUBSCRIBE,clientId:this._clientId,subscription:e},function(e){if(e.successful){var t=[].concat(e.subscription);this.info("Unsubscription acknowledged for ? from ?",this._clientId,t)}},this)},this)},publish:function(e,t){var n=new Faye.Publication;return this.connect(function(){this.info("Client ? queueing published message to ?: ?",this._clientId,e,t),this._send({channel:e,data:t,clientId:this._clientId},function(e){e.successful?n.setDeferredStatus("succeeded"):n.setDeferredStatus("failed",Faye.Error.parse(e.error))},this)},this),n},receiveMessage:function(e){var t,n=e.id;void 0!==e.successful&&(t=this._responseCallbacks[n],delete this._responseCallbacks[n]),this.pipeThroughExtensions("incoming",e,null,function(e){e&&(e.advice&&this._handleAdvice(e.advice),this._deliverMessage(e),t&&t[0].call(t[1],e))},this),this._transportUp!==!0&&(this._transportUp=!0,this.trigger("transport:up"))},messageError:function(e,t){for(var n,i,s=this._retry,r=this,o=0,a=e.length;a>o;o++)i=e[o],n=i.id,t?this._transportSend(i):Faye.ENV.setTimeout(function(){r._transportSend(i)},1e3*s);t||this._transportUp===!1||(this._transportUp=!1,this.trigger("transport:down"))},_selectTransport:function(e){Faye.Transport.get(this,e,this._disabled,function(e){this.debug("Selected ? transport for ?",e.connectionType,Faye.URI.stringify(e.endpoint)),e!==this._transport&&(this._transport&&this._transport.close(),this._transport=e)},this)},_send:function(e,t,n){this._transport&&(e.id=e.id||this._generateMessageId(),this.pipeThroughExtensions("outgoing",e,null,function(e){e&&(t&&(this._responseCallbacks[e.id]=[t,n]),this._transportSend(e))},this))},_transportSend:function(e){if(this._transport){var t=1.2*(this._advice.timeout||1e3*this._retry),n=new Faye.Envelope(e,t);n.errback(function(t){this.messageError([e],t)},this),this._transport.send(n)}},_generateMessageId:function(){return this._messageId+=1,this._messageId>=Math.pow(2,32)&&(this._messageId=0),this._messageId.toString(36)},_handleAdvice:function(e){Faye.extend(this._advice,e),this._advice.reconnect===this.HANDSHAKE&&this._state!==this.DISCONNECTED&&(this._state=this.UNCONNECTED,this._clientId=null,this._cycleConnection())},_deliverMessage:function(e){e.channel&&void 0!==e.data&&(this.info("Client ? calling listeners for ? with ?",this._clientId,e.channel,e.data),this._channels.distributeMessage(e))},_cycleConnection:function(){this._connectRequest&&(this._connectRequest=null,this.info("Closed connection for ?",this._clientId));var e=this;Faye.ENV.setTimeout(function(){e.connect()},this._advice.interval)}}),Faye.extend(Faye.Client.prototype,Faye.Deferrable),Faye.extend(Faye.Client.prototype,Faye.Publisher),Faye.extend(Faye.Client.prototype,Faye.Logging),Faye.extend(Faye.Client.prototype,Faye.Extensible),Faye.Transport=Faye.extend(Faye.Class({MAX_DELAY:0,batching:!0,initialize:function(e,t){this._client=e,this.endpoint=t,this._outbox=[]},close:function(){},encode:function(){return""},send:function(e){var t=e.message;return this.debug("Client ? sending message to ?: ?",this._client._clientId,Faye.URI.stringify(this.endpoint),t),this.batching?(this._outbox.push(e),t.channel===Faye.Channel.HANDSHAKE?this.addTimeout("publish",.01,this.flush,this):(t.channel===Faye.Channel.CONNECT&&(this._connectMessage=t),this.flushLargeBatch(),this.addTimeout("publish",this.MAX_DELAY,this.flush,this),void 0)):this.request([e])},flush:function(){this.removeTimeout("publish"),this._outbox.length>1&&this._connectMessage&&(this._connectMessage.advice={timeout:0}),this.request(this._outbox),this._connectMessage=null,this._outbox=[]},flushLargeBatch:function(){var e=this.encode(this._outbox);if(!(e.length<this._client.maxRequestSize)){var t=this._outbox.pop();this.flush(),t&&this._outbox.push(t)}},receive:function(e,t){for(var n=e.length;n--;)e[n].setDeferredStatus("succeeded");t=[].concat(t),this.debug("Client ? received from ?: ?",this._client._clientId,Faye.URI.stringify(this.endpoint),t);for(var i=0,n=t.length;n>i;i++)this._client.receiveMessage(t[i])},handleError:function(e,t){for(var n=e.length;n--;)e[n].setDeferredStatus("failed",t)},_getCookies:function(){var e=this._client.cookies;return e?e.getCookies({domain:this.endpoint.hostname,path:this.endpoint.path,secure:"https:"===this.endpoint.protocol}).toValueString():""},_storeCookies:function(e){if(e&&this._client.cookies){e=[].concat(e);for(var t,n=0,i=e.length;i>n;n++)t=this._client.cookies.setCookie(e[n]),t=t[0]||t,t.domain=t.domain||this.endpoint.hostname}}}),{get:function(e,t,n,i,s){var r=e.endpoint;Faye.asyncEach(this._transports,function(o,a){var c=o[0],u=o[1],h=e.endpoints[c]||r;return Faye.indexOf(n,c)>=0?a():Faye.indexOf(t,c)<0?(u.isUsable(e,h,function(){}),a()):(u.isUsable(e,h,function(t){if(!t)return a();var n=u.hasOwnProperty("create")?u.create(e,h):new u(e,h);i.call(s,n)}),void 0)},function(){throw Error("Could not find a usable connection type for "+Faye.URI.stringify(r))})},register:function(e,t){this._transports.push([e,t]),t.prototype.connectionType=e},_transports:[]}),Faye.extend(Faye.Transport.prototype,Faye.Logging),Faye.extend(Faye.Transport.prototype,Faye.Timeouts),Faye.Event={_registry:[],on:function(e,t,n,i){var s=function(){n.call(i)};e.addEventListener?e.addEventListener(t,s,!1):e.attachEvent("on"+t,s),this._registry.push({_element:e,_type:t,_callback:n,_context:i,_handler:s})},detach:function(e,t,n,i){for(var s,r=this._registry.length;r--;)s=this._registry[r],e&&e!==s._element||t&&t!==s._type||n&&n!==s._callback||i&&i!==s._context||(s._element.removeEventListener?s._element.removeEventListener(s._type,s._handler,!1):s._element.detachEvent("on"+s._type,s._handler),this._registry.splice(r,1),s=null)}},void 0!==Faye.ENV.onunload&&Faye.Event.on(Faye.ENV,"unload",Faye.Event.detach,Faye.Event),"object"!=typeof JSON&&(JSON={}),function(){function f(e){return 10>e?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,i,s,r,o,a=gap,c=t[e];switch(c&&"object"==typeof c&&"function"==typeof c.toJSON&&(c=c.toJSON(e)),"function"==typeof rep&&(c=rep.call(t,e,c)),typeof c){case"string":return quote(c);case"number":return isFinite(c)?c+"":"null";case"boolean":case"null":return c+"";case"object":if(!c)return"null";if(gap+=indent,o=[],"[object Array]"===Object.prototype.toString.apply(c)){for(r=c.length,n=0;r>n;n+=1)o[n]=str(n,c)||"null";return s=0===o.length?"[]":gap?"[\n"+gap+o.join(",\n"+gap)+"\n"+a+"]":"["+o.join(",")+"]",gap=a,s}if(rep&&"object"==typeof rep)for(r=rep.length,n=0;r>n;n+=1)"string"==typeof rep[n]&&(i=rep[n],s=str(i,c),s&&o.push(quote(i)+(gap?": ":":")+s));else for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(s=str(i,c),s&&o.push(quote(i)+(gap?": ":":")+s));return s=0===o.length?"{}":gap?"{\n"+gap+o.join(",\n"+gap)+"\n"+a+"}":"{"+o.join(",")+"}",gap=a,s}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;Faye.stringify=function(e,t,n){var i;if(gap="",indent="","number"==typeof n)for(i=0;n>i;i+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw Error("JSON.stringify");return str("",{"":e})},"function"!=typeof JSON.stringify&&(JSON.stringify=Faye.stringify),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(e,t){var n,i,s=e[t];if(s&&"object"==typeof s)for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(i=walk(s,n),void 0!==i?s[n]=i:delete s[n]);return reviver.call(e,t,s)}var j;if(text+="",cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),Faye.Transport.WebSocket=Faye.extend(Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:!1,isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)}),this.connect()},request:function(e){this.callback(function(t){if(t){for(var n=0,i=e.length;i>n;n++)this._pending.add(e[n]);var s=Faye.map(e,function(e){return e.message});t.send(Faye.toJSON(s))}},this),this.connect()},connect:function(){if(!Faye.Transport.WebSocket._unloaded&&(this._state=this._state||this.UNCONNECTED,this._state===this.UNCONNECTED)){this._state=this.CONNECTING;var e=this._createSocket();if(!e)return this.setDeferredStatus("failed");var t=this;e.onopen=function(){e.headers&&t._storeCookies(e.headers["set-cookie"]),t._socket=e,t._pending=new Faye.Set,t._state=t.CONNECTED,t._everConnected=!0,t._ping(),t.setDeferredStatus("succeeded",e)};var n=!1;e.onclose=e.onerror=function(){if(!n){n=!0;var i=t._state===t.CONNECTED;e.onopen=e.onclose=e.onerror=e.onmessage=null,delete t._socket,t._state=t.UNCONNECTED,t.removeTimeout("ping"),t.setDeferredStatus("unknown");var s=t._pending?t._pending.toArray():[];delete t._pending,i?t.handleError(s,!0):t._everConnected?t.handleError(s):t.setDeferredStatus("failed")}},e.onmessage=function(e){var n,i=JSON.parse(e.data),s=[];if(i){i=[].concat(i);for(var r=0,o=i.length;o>r;r++)void 0!==i[r].successful&&(n=t._pending.remove(i[r]),n&&s.push(n));t.receive(s,i)}}}},close:function(){this._socket&&this._socket.close()},_createSocket:function(){var e=Faye.Transport.WebSocket.getSocketUrl(this.endpoint),t={headers:Faye.copyObject(this._client.headers),ca:this._client.ca};return t.headers.Cookie=this._getCookies(),Faye.WebSocket?new Faye.WebSocket.Client(e,[],t):Faye.ENV.MozWebSocket?new MozWebSocket(e):Faye.ENV.WebSocket?new WebSocket(e):void 0},_ping:function(){this._socket&&(this._socket.send("[]"),this.addTimeout("ping",this._client._advice.timeout/2e3,this._ping,this))}}),{PROTOCOLS:{"http:":"ws:","https:":"wss:"},create:function(e,t){var n=e.transports.websocket=e.transports.websocket||{};return n[t.href]=n[t.href]||new this(e,t),n[t.href]},getSocketUrl:function(e){return e=Faye.copyObject(e),e.protocol=this.PROTOCOLS[e.protocol],Faye.URI.stringify(e)},isUsable:function(e,t,n,i){this.create(e,t).isUsable(n,i)}}),Faye.extend(Faye.Transport.WebSocket.prototype,Faye.Deferrable),Faye.Transport.register("websocket",Faye.Transport.WebSocket),Faye.Event&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.Transport.WebSocket._unloaded=!0}),Faye.Transport.EventSource=Faye.extend(Faye.Class(Faye.Transport,{initialize:function(e,t){if(Faye.Transport.prototype.initialize.call(this,e,t),!Faye.ENV.EventSource)return this.setDeferredStatus("failed");this._xhr=new Faye.Transport.XHR(e,t),t=Faye.copyObject(t),t.pathname+="/"+e._clientId;var n=new EventSource(Faye.URI.stringify(t)),i=this;n.onopen=function(){i._everConnected=!0,i.setDeferredStatus("succeeded")},n.onerror=function(){i._everConnected?i._client.messageError([]):(i.setDeferredStatus("failed"),n.close())},n.onmessage=function(e){i.receive([],JSON.parse(e.data))},this._socket=n},close:function(){this._socket&&(this._socket.onopen=this._socket.onerror=this._socket.onmessage=null,this._socket.close(),delete this._socket)},isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)})},encode:function(e){return this._xhr.encode(e)},request:function(e){this._xhr.request(e)}}),{isUsable:function(e,t,n,i){var s=e._clientId;return s?(Faye.Transport.XHR.isUsable(e,t,function(s){return s?(this.create(e,t).isUsable(n,i),void 0):n.call(i,!1)},this),void 0):n.call(i,!1)},create:function(e,t){var n=e.transports.eventsource=e.transports.eventsource||{},i=e._clientId;t=Faye.copyObject(t),t.pathname+="/"+(i||"");var s=Faye.URI.stringify(t);return n[s]=n[s]||new this(e,t),n[s]}}),Faye.extend(Faye.Transport.EventSource.prototype,Faye.Deferrable),Faye.Transport.register("eventsource",Faye.Transport.EventSource),Faye.Transport.XHR=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message
2
+ });return Faye.toJSON(t)},request:function(e){var t=this.endpoint.path,n=Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest,i=this;n.open("POST",t,!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Pragma","no-cache"),n.setRequestHeader("X-Requested-With","XMLHttpRequest");var s=this._client.headers;for(var r in s)s.hasOwnProperty(r)&&n.setRequestHeader(r,s[r]);var o=function(){n.abort()};Faye.Event.on(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){if(n&&4===n.readyState){var t=null,s=n.status,r=n.responseText,a=s>=200&&300>s||304===s||1223===s;if(Faye.Event.detach(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){},n=null,!a)return i.handleError(e);try{t=JSON.parse(r)}catch(c){}t?i.receive(e,t):i.handleError(e)}},n.send(this.encode(e))}}),{isUsable:function(e,t,n,i){n.call(i,Faye.URI.isSameOrigin(t))}}),Faye.Transport.register("long-polling",Faye.Transport.XHR),Faye.Transport.CORS=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message});return"message="+encodeURIComponent(Faye.toJSON(t))},request:function(e){var t,n=Faye.ENV.XDomainRequest?XDomainRequest:XMLHttpRequest,i=new n,s=this._client.headers,r=this;if(i.open("POST",Faye.URI.stringify(this.endpoint),!0),i.setRequestHeader){i.setRequestHeader("Pragma","no-cache");for(t in s)s.hasOwnProperty(t)&&i.setRequestHeader(t,s[t])}var o=function(){return i?(i.onload=i.onerror=i.ontimeout=i.onprogress=null,i=null,void 0):!1};i.onload=function(){var t=null;try{t=JSON.parse(i.responseText)}catch(n){}o(),t?r.receive(e,t):r.handleError(e)},i.onerror=i.ontimeout=function(){o(),r.handleError(e)},i.onprogress=function(){},i.send(this.encode(e))}}),{isUsable:function(e,t,n,i){if(Faye.URI.isSameOrigin(t))return n.call(i,!1);if(Faye.ENV.XDomainRequest)return n.call(i,t.protocol===Faye.ENV.location.protocol);if(Faye.ENV.XMLHttpRequest){var s=new Faye.ENV.XMLHttpRequest;return n.call(i,void 0!==s.withCredentials)}return n.call(i,!1)}}),Faye.Transport.register("cross-origin-long-polling",Faye.Transport.CORS),Faye.Transport.JSONP=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message}),n=Faye.copyObject(this.endpoint);return n.query.message=Faye.toJSON(t),n.query.jsonp="__jsonp"+Faye.Transport.JSONP._cbCount+"__",Faye.URI.stringify(n)},request:function(e){var t=Faye.map(e,function(e){return e.message}),n=document.getElementsByTagName("head")[0],i=document.createElement("script"),s=Faye.Transport.JSONP.getCallbackName(),r=Faye.copyObject(this.endpoint),o=this;r.query.message=Faye.toJSON(t),r.query.jsonp=s,Faye.ENV[s]=function(t){if(!Faye.ENV[s])return!1;Faye.ENV[s]=void 0;try{delete Faye.ENV[s]}catch(n){}i.parentNode.removeChild(i),o.receive(e,t)},i.type="text/javascript",i.src=Faye.URI.stringify(r),n.appendChild(i)}}),{_cbCount:0,getCallbackName:function(){return this._cbCount+=1,"__jsonp"+this._cbCount+"__"},isUsable:function(e,t,n,i){n.call(i,!0)}}),Faye.Transport.register("callback-polling",Faye.Transport.JSONP)}();
2
3
  //@ sourceMappingURL=faye-browser-min.js.map
@@ -1,8 +1 @@
1
- {
2
- "version": 3,
3
- "file": "faye-browser-min.js",
4
- "sourceRoot": "",
5
- "sources": ["faye-browser.js"],
6
- "names": ["_advice", "_callback", "_callbacks", "_cancelled", "_cbCount", "_channels", "_client", "_clientId", "_connectMessage", "_connectRequest", "_context", "_cookies", "_cycleConnection", "_deferredArgs", "_deferredStatus", "_deliverMessage", "_disabled", "_element", "_errbacks", "_everConnected", "_extensions", "_generateMessageId", "_handleAdvice", "_handler", "_headers", "_messageId", "_messages", "_options", "_outbox", "_registry", "_responseCallbacks", "_selectTransport", "_send", "_socket", "_state", "_subscribers", "_teardownConnection", "_this", "_timeout", "_timeouts", "_timer", "_transport", "_transportUp", "_transports", "_type", "_unloaded", "_used", "_xhr", "abort", "advice", "allowed", "args", "array", "banner", "bitlength", "bridge", "c", "callback", "callbackName", "callbacks", "called", "calls", "channel", "channels", "chars", "cleanUp", "client", "clone", "code", "connEndpoint", "connType", "consume", "context", "copy", "cx", "data", "date", "day", "dead", "delay", "dest", "disabled", "element", "endpoint", "escapable", "event", "eventName", "eventType", "extension", "extensions", "external", "f", "feature", "first", "force", "gap", "hasSubscribe", "head", "headers", "holder", "host", "hour", "i", "id", "indent", "infer", "isUsable", "iterate", "iterator", "j", "k", "key", "keys", "klass", "length", "level", "levels", "limit", "list", "lista", "listb", "listener", "listeners", "location", "loop", "looping", "match", "maxSize", "message", "messageArgs", "messages", "meta", "methods", "mind", "minute", "month", "msg", "n", "name", "names", "needle", "object", "onerror", "options", "overwrite", "pad", "pair", "pairs", "params", "parent", "parsedMessage", "partial", "parts", "path", "pattern", "pipe", "publication", "query", "quote", "register", "rep", "replacer", "response", "responses", "result", "resume", "retry", "reviver", "script", "second", "seconds", "segments", "self", "socket", "sockets", "source", "space", "stage", "status", "str", "string", "subscription", "successful", "text", "timeout", "timer", "transport", "transportTypes", "type", "uri", "url", "usable", "v", "value", "walk", "wasConnected", "wrapped", "ws", "xhr", "xhrClass", "year"],
7
- "mappings": "CAAC,IAAI,QAEL,IAAI,MACF,iBAEA,qBACA,cACA,gBAAmB,eACnB,mBAAoB,KAAK,UAAW,MAAM,OAAO,KAAK,UAAW,SAAS,UAAW,YAAa,cAAe,GAAG,UAEpH,6BAA8B,KAAK,UAAW,SAAS,UAAW,GAAG,UAErE,KAAM,OAAO,UAAY,YAAc,OAAS,OAEhD,OAAQ,SAASgF,EAAM+F,EAAQ/B,GAC7B,IAAK+B,EAAQ,OAAO/F,EACpB,IAAK,IAAI+B,EAAI,GAAGgE,GACd,IAAKA,EAAO,eAAehE,GAAM,SACjC,GAAI/B,EAAK,eAAe+B,IAAQiC,IAAc,MAAO,SACrD,GAAIhE,EAAK+B,KAASgE,EAAOhE,GACvB/B,EAAK+B,GAAOgE,EAAOhE,GAEvB,OAAO/B,GAGT,OAAQ,SAAS1B,GACfA,EAAYA,GAAa,KAAK,UAC9B,GAAIA,MACF,IAAIkG,EAAS,KAAK,KAAKlG,MACnB8H,KACJ,MAAO5B,IAAS4B,GAAU,KAAK,WAC/B,IAAIpH,EAAQoH,EAAO,UAAWhB,KAC9B,MAAOpG,EAAM,SAAYoG,GAAUpG,EAAM,MACzC,OAAOoG,EAET,IAAI/C,EAAU,KAAK,MAAO/D,KACtByE,EAAUV,EAAM,aAAa,OAC7B+D,EAAU,KAAK,MAAM,KAAK,SAAW/D,GAAO,aAE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AAK,SAAS,iBACAY,GAEhB,IAAIvH,EAAU,WACZ,IAAK,KAAK,IAAIP,GAAe,OAAO,MACpC,KAAK,IAAIA,GAAgB,UACzB,IAAM,OAAO,KAAK,IAAIA,GAAgB,MAAO,IAC7C,KAAK,IAAI,aAAa+H,GACtBjB,EAAO,WAAW,YAAYA,GAC9B,OAAO,MAGT7C,EAAS,OAAO,MAAQjE,EACxB8G,EAAO,MAAQ,KAAK,YACpBA,EAAO,IAAO7C,EAAS,QACvB1B,EAAK,YAAYuE,OAGnBpK,KAEA,gBAAiB,WACf,KAAKA,MACL,OAAQ,SAAW,KAAKA,IAAY,KAGtC,SAAU,SAAS8D,EAAQiB,EAAU1B,EAAUe,GAC7Cf,EAAS,KAAKe,EAAS,SAI3B,KAAK,UAAU,UAAU,SAAS,SAAU,KAAK,UAAU;"
8
- }
1
+ {"version":3,"file":"faye-browser-min.js","sources":["faye-browser.js"],"names":["Faye","VERSION","BAYEUX_VERSION","ID_LENGTH","JSONP_CALLBACK","CONNECTION_TYPES","MANDATORY_CONNECTION_TYPES","ENV","window","global","extend","dest","source","overwrite","key","hasOwnProperty","random","bitlength","this","csprng","clientIdFromMessages","messages","connect","filter","concat","message","channel","clientId","copyObject","object","clone","i","Array","length","commonElement","lista","listb","n","indexOf","list","needle","map","callback","context","result","push","call","array","asyncEach","iterator","calls","looping","iterate","resume","loop","toJSON","stringify","value","JSON","module","exports","Class","parent","methods","Object","klass","initialize","apply","arguments","bridge","prototype","xs","x","EventEmitter","isArray","toString","emit","type","_events","error","Error","handler","args","slice","listeners","l","addListener","listener","on","once","self","g","removeListener","splice","removeAllListeners","Namespace","_used","exists","id","generate","name","release","defer","timeout","setTimeout","setImmediate","fn","process","nextTick","PENDING","FULFILLED","REJECTED","FORWARD","BREAK","Promise","task","_state","_callbacks","_errbacks","fulfill","reason","reject","then","errback","next","registerCallback","registerErrback","promise","invoke","_value","_reason","outcome","cb","callbacks","shift","eb","errbacks","pending","tuple","fulfilled","rejected","Set","_index","add","item","undefined","forEach","block","isEmpty","member","remove","removed","toArray","URI","isURI","uri","protocol","host","path","isSameOrigin","location","hostname","port","parse","url","parts","query","pairs","data","consume","pattern","replace","match","test","pathname","substr","split","search","decodeURIComponent","href","string","queryString","hash","encodeURIComponent","join","code","params","Grammar","ERROR","parseInt","versionMismatch","conntypeMismatch","extMismatch","badRequest","clientUnknown","parameterMissing","channelForbidden","channelUnknown","channelInvalid","extUnknown","publishFailed","serverError","Deferrable","_promise","_fulfill","_reject","seconds","_timer","setDeferredStatus","status","clearTimeout","Publisher","countListeners","eventType","bind","_listeners","unbind","trigger","Timeouts","addTimeout","delay","_timeouts","removeTimeout","Logging","LOG_LEVELS","fatal","warn","info","debug","writeLog","messageArgs","level","logger","banner","className","e","CHANNEL_NAME","CHANNEL_PATTERN","Extensible","addExtension","extension","_extensions","added","removeExtension","pipeThroughExtensions","stage","request","extensions","pipe","Channel","isUnused","HANDSHAKE","CONNECT","SUBSCRIBE","UNSUBSCRIBE","DISCONNECT","META","SERVICE","expand","segments","channels","copy","unparse","isValid","isMeta","isService","isSubscribable","_channels","getKeys","keys","hasSubscription","subscribe","names","unsubscribe","distributeMessage","Envelope","Publication","Subscription","client","_client","_callback","_context","_cancelled","cancel","Client","UNCONNECTED","CONNECTING","CONNECTED","DISCONNECTED","RETRY","NONE","CONNECTION_TIMEOUT","DEFAULT_RETRY","MAX_REQUEST_SIZE","DEFAULT_ENDPOINT","INTERVAL","endpoint","options","_options","endpoints","transports","cookies","CookieJar","headers","ca","_disabled","_retry","retry","maxRequestSize","_messageId","_responseCallbacks","_advice","reconnect","interval","Event","onbeforeunload","disconnect","disable","feature","setHeader","handshake","_selectTransport","_send","version","supportedConnectionTypes","_transport","connectionType","response","successful","_clientId","_connectRequest","_cycleConnection","close","c","subscription","force","hasSubscribe","dead","publish","publication","receiveMessage","advice","_handleAdvice","_deliverMessage","_transportUp","messageError","immediate","_transportSend","transportTypes","Transport","get","transport","_generateMessageId","envelope","send","Math","pow","MAX_DELAY","batching","_outbox","encode","flush","_connectMessage","flushLargeBatch","last","pop","receive","envelopes","responses","handleError","_getCookies","getCookies","domain","secure","toValueString","_storeCookies","setCookie","cookie","allowed","disabled","_transports","pair","connType","connEndpoint","isUsable","create","register","_registry","element","eventName","wrapped","addEventListener","attachEvent","_element","_type","_handler","detach","removeEventListener","detachEvent","onunload","f","quote","escapable","lastIndex","a","meta","charCodeAt","str","holder","k","v","partial","mind","gap","rep","isFinite","String","indent","Date","valueOf","getUTCFullYear","getUTCMonth","getUTCDate","getUTCHours","getUTCMinutes","getUTCSeconds","Number","Boolean","cx","\b","\t","\n","\f","\r","\"","\\","replacer","space","text","reviver","walk","j","eval","SyntaxError","WebSocket","socket","_pending","_unloaded","_createSocket","onopen","_socket","_everConnected","_ping","closed","onclose","onerror","wasConnected","onmessage","event","getSocketUrl","MozWebSocket","PROTOCOLS","http:","https:","sockets","websocket","EventSource","_xhr","XHR","usable","eventsource","xhr","ActiveXObject","XMLHttpRequest","open","setRequestHeader","abort","onreadystatechange","readyState","parsedMessage","responseText","CORS","xhrClass","XDomainRequest","cleanUp","onload","ontimeout","onprogress","withCredentials","JSONP","jsonp","_cbCount","head","document","getElementsByTagName","script","createElement","callbackName","getCallbackName","parentNode","removeChild","src","appendChild"],"mappings":"CAAA,WACA,YAEA,IAAIA,OACFC,QAAkB,QAElBC,eAAkB,MAClBC,UAAkB,IAClBC,eAAkB,gBAClBC,kBAAmB,eAAgB,4BAA6B,mBAAoB,YAAa,cAAe,cAEhHC,4BAA6B,eAAgB,mBAAoB,cAEjEC,IAAwB,mBAAXC,QAA0BA,OAASC,OAEhDC,OAAQ,SAASC,EAAMC,EAAQC,GAC7B,IAAKD,EAAQ,MAAOD,EACpB,KAAK,GAAIG,KAAOF,GACTA,EAAOG,eAAeD,KACvBH,EAAKI,eAAeD,IAAQD,KAAc,GAC1CF,EAAKG,KAASF,EAAOE,KACvBH,EAAKG,GAAOF,EAAOE,IAEvB,OAAOH,IAGTK,OAAQ,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mBAAoBlY,KAAK6V,UAAU4I"}
@@ -1,7 +1,8 @@
1
+ (function() {
1
2
  'use strict';
2
3
 
3
4
  var Faye = {
4
- VERSION: '0.8.11',
5
+ VERSION: '1.0.0',
5
6
 
6
7
  BAYEUX_VERSION: '1.0',
7
8
  ID_LENGTH: 160,
@@ -10,7 +11,7 @@ var Faye = {
10
11
 
11
12
  MANDATORY_CONNECTION_TYPES: ['long-polling', 'callback-polling', 'in-process'],
12
13
 
13
- ENV: (typeof global === 'undefined') ? window : global,
14
+ ENV: (typeof window !== 'undefined') ? window : global,
14
15
 
15
16
  extend: function(dest, source, overwrite) {
16
17
  if (!source) return dest;
@@ -25,25 +26,14 @@ var Faye = {
25
26
 
26
27
  random: function(bitlength) {
27
28
  bitlength = bitlength || this.ID_LENGTH;
28
- if (bitlength > 32) {
29
- var parts = Math.ceil(bitlength / 32),
30
- string = '';
31
- while (parts--) string += this.random(32);
32
- var chars = string.split(''), result = '';
33
- while (chars.length > 0) result += chars.pop();
34
- return result;
35
- }
36
- var limit = Math.pow(2, bitlength) - 1,
37
- maxSize = limit.toString(36).length,
38
- string = Math.floor(Math.random() * limit).toString(36);
39
-
40
- while (string.length < maxSize) string = '0' + string;
41
- return string;
29
+ return csprng(bitlength, 36);
42
30
  },
43
31
 
44
32
  clientIdFromMessages: function(messages) {
45
- var first = [].concat(messages)[0];
46
- return first && first.clientId;
33
+ var connect = this.filter([].concat(messages), function(message) {
34
+ return message.channel === '/meta/connect';
35
+ });
36
+ return connect[0] && connect[0].clientId;
47
37
  },
48
38
 
49
39
  copyObject: function(object) {
@@ -97,6 +87,7 @@ var Faye = {
97
87
  },
98
88
 
99
89
  filter: function(array, callback, context) {
90
+ if (array.filter) return array.filter(callback, context);
100
91
  var result = [];
101
92
  for (var i = 0, n = array.length; i < n; i++) {
102
93
  if (callback.call(context || null, array[i], i))
@@ -134,42 +125,19 @@ var Faye = {
134
125
 
135
126
  // http://assanka.net/content/tech/2009/09/02/json2-js-vs-prototype/
136
127
  toJSON: function(object) {
137
- if (this.stringify)
138
- return this.stringify(object, function(key, value) {
139
- return (this[key] instanceof Array)
140
- ? this[key]
141
- : value;
142
- });
143
-
144
- return JSON.stringify(object);
145
- },
128
+ if (!this.stringify) return JSON.stringify(object);
146
129
 
147
- logger: function(message) {
148
- if (typeof console !== 'undefined') console.log(message);
149
- },
150
-
151
- timestamp: function() {
152
- var date = new Date(),
153
- year = date.getFullYear(),
154
- month = date.getMonth() + 1,
155
- day = date.getDate(),
156
- hour = date.getHours(),
157
- minute = date.getMinutes(),
158
- second = date.getSeconds();
159
-
160
- var pad = function(n) {
161
- return n < 10 ? '0' + n : String(n);
162
- };
163
-
164
- return pad(year) + '-' + pad(month) + '-' + pad(day) + ' ' +
165
- pad(hour) + ':' + pad(minute) + ':' + pad(second);
130
+ return this.stringify(object, function(key, value) {
131
+ return (this[key] instanceof Array) ? this[key] : value;
132
+ });
166
133
  }
167
134
  };
168
135
 
169
- if (typeof window !== 'undefined')
136
+ if (typeof module !== 'undefined')
137
+ module.exports = Faye;
138
+ else if (typeof window !== 'undefined')
170
139
  window.Faye = Faye;
171
140
 
172
-
173
141
  Faye.Class = function(parent, methods) {
174
142
  if (typeof parent !== 'function') {
175
143
  methods = parent;
@@ -190,6 +158,180 @@ Faye.Class = function(parent, methods) {
190
158
  return klass;
191
159
  };
192
160
 
161
+ (function() {
162
+ var EventEmitter = Faye.EventEmitter = function() {};
163
+
164
+ /*
165
+ Copyright Joyent, Inc. and other Node contributors. All rights reserved.
166
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
167
+ this software and associated documentation files (the "Software"), to deal in
168
+ the Software without restriction, including without limitation the rights to
169
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
170
+ of the Software, and to permit persons to whom the Software is furnished to do
171
+ so, subject to the following conditions:
172
+
173
+ The above copyright notice and this permission notice shall be included in all
174
+ copies or substantial portions of the Software.
175
+
176
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
179
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
180
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
181
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
182
+ SOFTWARE.
183
+ */
184
+
185
+ var isArray = typeof Array.isArray === 'function'
186
+ ? Array.isArray
187
+ : function (xs) {
188
+ return Object.prototype.toString.call(xs) === '[object Array]'
189
+ }
190
+ ;
191
+ function indexOf (xs, x) {
192
+ if (xs.indexOf) return xs.indexOf(x);
193
+ for (var i = 0; i < xs.length; i++) {
194
+ if (x === xs[i]) return i;
195
+ }
196
+ return -1;
197
+ }
198
+
199
+
200
+ EventEmitter.prototype.emit = function(type) {
201
+ // If there is no 'error' event listener then throw.
202
+ if (type === 'error') {
203
+ if (!this._events || !this._events.error ||
204
+ (isArray(this._events.error) && !this._events.error.length))
205
+ {
206
+ if (arguments[1] instanceof Error) {
207
+ throw arguments[1]; // Unhandled 'error' event
208
+ } else {
209
+ throw new Error("Uncaught, unspecified 'error' event.");
210
+ }
211
+ return false;
212
+ }
213
+ }
214
+
215
+ if (!this._events) return false;
216
+ var handler = this._events[type];
217
+ if (!handler) return false;
218
+
219
+ if (typeof handler == 'function') {
220
+ switch (arguments.length) {
221
+ // fast cases
222
+ case 1:
223
+ handler.call(this);
224
+ break;
225
+ case 2:
226
+ handler.call(this, arguments[1]);
227
+ break;
228
+ case 3:
229
+ handler.call(this, arguments[1], arguments[2]);
230
+ break;
231
+ // slower
232
+ default:
233
+ var args = Array.prototype.slice.call(arguments, 1);
234
+ handler.apply(this, args);
235
+ }
236
+ return true;
237
+
238
+ } else if (isArray(handler)) {
239
+ var args = Array.prototype.slice.call(arguments, 1);
240
+
241
+ var listeners = handler.slice();
242
+ for (var i = 0, l = listeners.length; i < l; i++) {
243
+ listeners[i].apply(this, args);
244
+ }
245
+ return true;
246
+
247
+ } else {
248
+ return false;
249
+ }
250
+ };
251
+
252
+ // EventEmitter is defined in src/node_events.cc
253
+ // EventEmitter.prototype.emit() is also defined there.
254
+ EventEmitter.prototype.addListener = function(type, listener) {
255
+ if ('function' !== typeof listener) {
256
+ throw new Error('addListener only takes instances of Function');
257
+ }
258
+
259
+ if (!this._events) this._events = {};
260
+
261
+ // To avoid recursion in the case that type == "newListeners"! Before
262
+ // adding it to the listeners, first emit "newListeners".
263
+ this.emit('newListener', type, listener);
264
+
265
+ if (!this._events[type]) {
266
+ // Optimize the case of one listener. Don't need the extra array object.
267
+ this._events[type] = listener;
268
+ } else if (isArray(this._events[type])) {
269
+ // If we've already got an array, just append.
270
+ this._events[type].push(listener);
271
+ } else {
272
+ // Adding the second element, need to change to array.
273
+ this._events[type] = [this._events[type], listener];
274
+ }
275
+
276
+ return this;
277
+ };
278
+
279
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
280
+
281
+ EventEmitter.prototype.once = function(type, listener) {
282
+ var self = this;
283
+ self.on(type, function g() {
284
+ self.removeListener(type, g);
285
+ listener.apply(this, arguments);
286
+ });
287
+
288
+ return this;
289
+ };
290
+
291
+ EventEmitter.prototype.removeListener = function(type, listener) {
292
+ if ('function' !== typeof listener) {
293
+ throw new Error('removeListener only takes instances of Function');
294
+ }
295
+
296
+ // does not use listeners(), so no side effect of creating _events[type]
297
+ if (!this._events || !this._events[type]) return this;
298
+
299
+ var list = this._events[type];
300
+
301
+ if (isArray(list)) {
302
+ var i = indexOf(list, listener);
303
+ if (i < 0) return this;
304
+ list.splice(i, 1);
305
+ if (list.length == 0)
306
+ delete this._events[type];
307
+ } else if (this._events[type] === listener) {
308
+ delete this._events[type];
309
+ }
310
+
311
+ return this;
312
+ };
313
+
314
+ EventEmitter.prototype.removeAllListeners = function(type) {
315
+ if (arguments.length === 0) {
316
+ this._events = {};
317
+ return this;
318
+ }
319
+
320
+ // does not use listeners(), so no side effect of creating _events[type]
321
+ if (type && this._events && this._events[type]) this._events[type] = null;
322
+ return this;
323
+ };
324
+
325
+ EventEmitter.prototype.listeners = function(type) {
326
+ if (!this._events) this._events = {};
327
+ if (!this._events[type]) this._events[type] = [];
328
+ if (!isArray(this._events[type])) {
329
+ this._events[type] = [this._events[type]];
330
+ }
331
+ return this._events[type];
332
+ };
333
+
334
+ })();
193
335
 
194
336
  Faye.Namespace = Faye.Class({
195
337
  initialize: function() {
@@ -212,6 +354,258 @@ Faye.Namespace = Faye.Class({
212
354
  }
213
355
  });
214
356
 
357
+ (function() {
358
+ 'use strict';
359
+
360
+ var timeout = setTimeout;
361
+
362
+ var defer;
363
+ if (typeof setImmediate === 'function')
364
+ defer = function(fn) { setImmediate(fn) };
365
+ else if (typeof process === 'object' && process.nextTick)
366
+ defer = function(fn) { process.nextTick(fn) };
367
+ else
368
+ defer = function(fn) { timeout(fn, 0) };
369
+
370
+ var PENDING = 0,
371
+ FULFILLED = 1,
372
+ REJECTED = 2;
373
+
374
+ var FORWARD = function(x) { return x },
375
+ BREAK = function(x) { throw x };
376
+
377
+ var Promise = function(task) {
378
+ this._state = PENDING;
379
+ this._callbacks = [];
380
+ this._errbacks = [];
381
+
382
+ if (typeof task !== 'function') return;
383
+ var self = this;
384
+
385
+ task(function(value) { fulfill(self, value) },
386
+ function(reason) { reject(self, reason) });
387
+ };
388
+
389
+ Promise.prototype.then = function(callback, errback) {
390
+ var self = this;
391
+ return new Promise(function(fulfill, reject) {
392
+ var next = {fulfill: fulfill, reject: reject};
393
+ registerCallback(self, callback, next);
394
+ registerErrback(self, errback, next);
395
+ });
396
+ };
397
+
398
+ var registerCallback = function(promise, callback, next) {
399
+ if (typeof callback !== 'function') callback = FORWARD;
400
+ var handler = function(value) { invoke(callback, value, next) };
401
+ if (promise._state === PENDING) {
402
+ promise._callbacks.push(handler);
403
+ } else if (promise._state === FULFILLED) {
404
+ defer(function() { handler(promise._value) });
405
+ }
406
+ };
407
+
408
+ var registerErrback = function(promise, errback, next) {
409
+ if (typeof errback !== 'function') errback = BREAK;
410
+ var handler = function(reason) { invoke(errback, reason, next) };
411
+ if (promise._state === PENDING) {
412
+ promise._errbacks.push(handler);
413
+ } else if (promise._state === REJECTED) {
414
+ defer(function() { handler(promise._reason) });
415
+ }
416
+ };
417
+
418
+ var invoke = function(fn, value, next) {
419
+ try {
420
+ var outcome = fn(value);
421
+ if (outcome && typeof outcome.then === 'function') {
422
+ outcome.then(next.fulfill, next.reject);
423
+ } else {
424
+ next.fulfill(outcome);
425
+ }
426
+ } catch (error) {
427
+ next.reject(error);
428
+ }
429
+ };
430
+
431
+ var fulfill = Promise.fulfill = function(promise, value) {
432
+ if (promise._state !== PENDING) return;
433
+
434
+ promise._state = FULFILLED;
435
+ promise._value = value;
436
+ promise._errbacks = [];
437
+
438
+ var callbacks = promise._callbacks, cb;
439
+ while (cb = callbacks.shift()) cb(value);
440
+ };
441
+
442
+ var reject = Promise.reject = function(promise, reason) {
443
+ if (promise._state !== PENDING) return;
444
+
445
+ promise._state = REJECTED;
446
+ promise._reason = reason;
447
+ promise._callbacks = [];
448
+
449
+ var errbacks = promise._errbacks, eb;
450
+ while (eb = errbacks.shift()) eb(reason);
451
+ };
452
+
453
+ Promise.defer = defer;
454
+
455
+ Promise.pending = function() {
456
+ var tuple = {};
457
+
458
+ tuple.promise = new Promise(function(fulfill, reject) {
459
+ tuple.fulfill = fulfill;
460
+ tuple.reject = reject;
461
+ });
462
+ return tuple;
463
+ };
464
+
465
+ Promise.fulfilled = function(value) {
466
+ return new Promise(function(fulfill, reject) { fulfill(value) });
467
+ };
468
+
469
+ Promise.rejected = function(reason) {
470
+ return new Promise(function(fulfill, reject) { reject(reason) });
471
+ };
472
+
473
+ if (typeof Faye === 'undefined')
474
+ module.exports = Promise;
475
+ else
476
+ Faye.Promise = Promise;
477
+
478
+ })();
479
+
480
+ Faye.Set = Faye.Class({
481
+ initialize: function() {
482
+ this._index = {};
483
+ },
484
+
485
+ add: function(item) {
486
+ var key = (item.id !== undefined) ? item.id : item;
487
+ if (this._index.hasOwnProperty(key)) return false;
488
+ this._index[key] = item;
489
+ return true;
490
+ },
491
+
492
+ forEach: function(block, context) {
493
+ for (var key in this._index) {
494
+ if (this._index.hasOwnProperty(key))
495
+ block.call(context, this._index[key]);
496
+ }
497
+ },
498
+
499
+ isEmpty: function() {
500
+ for (var key in this._index) {
501
+ if (this._index.hasOwnProperty(key)) return false;
502
+ }
503
+ return true;
504
+ },
505
+
506
+ member: function(item) {
507
+ for (var key in this._index) {
508
+ if (this._index[key] === item) return true;
509
+ }
510
+ return false;
511
+ },
512
+
513
+ remove: function(item) {
514
+ var key = (item.id !== undefined) ? item.id : item;
515
+ var removed = this._index[key];
516
+ delete this._index[key];
517
+ return removed;
518
+ },
519
+
520
+ toArray: function() {
521
+ var array = [];
522
+ this.forEach(function(item) { array.push(item) });
523
+ return array;
524
+ }
525
+ });
526
+
527
+ Faye.URI = {
528
+ isURI: function(uri) {
529
+ return uri && uri.protocol && uri.host && uri.path;
530
+ },
531
+
532
+ isSameOrigin: function(uri) {
533
+ var location = Faye.ENV.location;
534
+ return uri.protocol === location.protocol &&
535
+ uri.hostname === location.hostname &&
536
+ uri.port === location.port;
537
+ },
538
+
539
+ parse: function(url) {
540
+ if (typeof url !== 'string') return url;
541
+ var uri = {}, parts, query, pairs, i, n, data;
542
+
543
+ var consume = function(name, pattern) {
544
+ url = url.replace(pattern, function(match) {
545
+ uri[name] = match;
546
+ return '';
547
+ });
548
+ uri[name] = uri[name] || '';
549
+ };
550
+
551
+ consume('protocol', /^[a-z]+\:/i);
552
+ consume('host', /^\/\/[^\/\?#]+/);
553
+
554
+ if (!/^\//.test(url) && !uri.host)
555
+ url = Faye.ENV.location.pathname.replace(/[^\/]*$/, '') + url;
556
+
557
+ consume('pathname', /^[^\?#]*/);
558
+ consume('search', /^\?[^#]*/);
559
+ consume('hash', /^#.*/);
560
+
561
+ uri.protocol = uri.protocol || Faye.ENV.location.protocol;
562
+
563
+ if (uri.host) {
564
+ uri.host = uri.host.substr(2);
565
+ parts = uri.host.split(':');
566
+ uri.hostname = parts[0];
567
+ uri.port = parts[1] || '';
568
+ } else {
569
+ uri.host = Faye.ENV.location.host;
570
+ uri.hostname = Faye.ENV.location.hostname;
571
+ uri.port = Faye.ENV.location.port;
572
+ }
573
+
574
+ uri.pathname = uri.pathname || '/';
575
+ uri.path = uri.pathname + uri.search;
576
+
577
+ query = uri.search.replace(/^\?/, '');
578
+ pairs = query ? query.split('&') : [];
579
+ data = {};
580
+
581
+ for (i = 0, n = pairs.length; i < n; i++) {
582
+ parts = pairs[i].split('=');
583
+ data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');
584
+ }
585
+
586
+ uri.query = data;
587
+
588
+ uri.href = this.stringify(uri);
589
+ return uri;
590
+ },
591
+
592
+ stringify: function(uri) {
593
+ var string = uri.protocol + '//' + uri.hostname;
594
+ if (uri.port) string += ':' + uri.port;
595
+ string += uri.pathname + this.queryString(uri.query) + (uri.hash || '');
596
+ return string;
597
+ },
598
+
599
+ queryString: function(query) {
600
+ var pairs = [];
601
+ for (var key in query) {
602
+ if (!query.hasOwnProperty(key)) continue;
603
+ pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(query[key]));
604
+ }
605
+ if (pairs.length === 0) return '';
606
+ return '?' + pairs.join('&');
607
+ }
608
+ };
215
609
 
216
610
  Faye.Error = Faye.Class({
217
611
  initialize: function(code, params, message) {
@@ -240,155 +634,132 @@ Faye.Error.parse = function(message) {
240
634
  };
241
635
 
242
636
 
637
+
638
+
243
639
  Faye.Error.versionMismatch = function() {
244
- return new this(300, arguments, "Version mismatch").toString();
640
+ return new this(300, arguments, 'Version mismatch').toString();
245
641
  };
246
642
 
247
643
  Faye.Error.conntypeMismatch = function() {
248
- return new this(301, arguments, "Connection types not supported").toString();
644
+ return new this(301, arguments, 'Connection types not supported').toString();
249
645
  };
250
646
 
251
647
  Faye.Error.extMismatch = function() {
252
- return new this(302, arguments, "Extension mismatch").toString();
648
+ return new this(302, arguments, 'Extension mismatch').toString();
253
649
  };
254
650
 
255
651
  Faye.Error.badRequest = function() {
256
- return new this(400, arguments, "Bad request").toString();
652
+ return new this(400, arguments, 'Bad request').toString();
257
653
  };
258
654
 
259
655
  Faye.Error.clientUnknown = function() {
260
- return new this(401, arguments, "Unknown client").toString();
656
+ return new this(401, arguments, 'Unknown client').toString();
261
657
  };
262
658
 
263
659
  Faye.Error.parameterMissing = function() {
264
- return new this(402, arguments, "Missing required parameter").toString();
660
+ return new this(402, arguments, 'Missing required parameter').toString();
265
661
  };
266
662
 
267
663
  Faye.Error.channelForbidden = function() {
268
- return new this(403, arguments, "Forbidden channel").toString();
664
+ return new this(403, arguments, 'Forbidden channel').toString();
269
665
  };
270
666
 
271
667
  Faye.Error.channelUnknown = function() {
272
- return new this(404, arguments, "Unknown channel").toString();
668
+ return new this(404, arguments, 'Unknown channel').toString();
273
669
  };
274
670
 
275
671
  Faye.Error.channelInvalid = function() {
276
- return new this(405, arguments, "Invalid channel").toString();
672
+ return new this(405, arguments, 'Invalid channel').toString();
277
673
  };
278
674
 
279
675
  Faye.Error.extUnknown = function() {
280
- return new this(406, arguments, "Unknown extension").toString();
676
+ return new this(406, arguments, 'Unknown extension').toString();
281
677
  };
282
678
 
283
679
  Faye.Error.publishFailed = function() {
284
- return new this(407, arguments, "Failed to publish").toString();
680
+ return new this(407, arguments, 'Failed to publish').toString();
285
681
  };
286
682
 
287
683
  Faye.Error.serverError = function() {
288
- return new this(500, arguments, "Internal server error").toString();
684
+ return new this(500, arguments, 'Internal server error').toString();
289
685
  };
290
686
 
291
687
 
292
-
293
688
  Faye.Deferrable = {
294
- callback: function(callback, context) {
295
- if (!callback) return;
296
-
297
- if (this._deferredStatus === 'succeeded')
298
- return callback.apply(context, this._deferredArgs);
689
+ then: function(callback, errback) {
690
+ var self = this;
691
+ if (!this._promise)
692
+ this._promise = new Faye.Promise(function(fulfill, reject) {
693
+ self._fulfill = fulfill;
694
+ self._reject = reject;
695
+ });
299
696
 
300
- this._callbacks = this._callbacks || [];
301
- this._callbacks.push([callback, context]);
697
+ if (arguments.length === 0)
698
+ return this._promise;
699
+ else
700
+ return this._promise.then(callback, errback);
302
701
  },
303
702
 
304
- timeout: function(seconds, message) {
305
- var _this = this;
306
- var timer = Faye.ENV.setTimeout(function() {
307
- _this.setDeferredStatus('failed', message);
308
- }, seconds * 1000);
309
- this._timer = timer;
703
+ callback: function(callback, context) {
704
+ return this.then(function(value) { callback.call(context, value) });
310
705
  },
311
706
 
312
707
  errback: function(callback, context) {
313
- if (!callback) return;
314
-
315
- if (this._deferredStatus === 'failed')
316
- return callback.apply(context, this._deferredArgs);
317
-
318
- this._errbacks = this._errbacks || [];
319
- this._errbacks.push([callback, context]);
708
+ return this.then(null, function(reason) { callback.call(context, reason) });
320
709
  },
321
710
 
322
- setDeferredStatus: function() {
323
- if (this._timer)
324
- Faye.ENV.clearTimeout(this._timer);
711
+ timeout: function(seconds, message) {
712
+ this.then();
713
+ var self = this;
714
+ this._timer = Faye.ENV.setTimeout(function() {
715
+ self._reject(message);
716
+ }, seconds * 1000);
717
+ },
325
718
 
326
- var args = Array.prototype.slice.call(arguments),
327
- status = args.shift(),
328
- callbacks;
719
+ setDeferredStatus: function(status, value) {
720
+ if (this._timer) Faye.ENV.clearTimeout(this._timer);
329
721
 
330
- this._deferredStatus = status;
331
- this._deferredArgs = args;
722
+ var promise = this.then();
332
723
 
333
724
  if (status === 'succeeded')
334
- callbacks = this._callbacks;
725
+ this._fulfill(value);
335
726
  else if (status === 'failed')
336
- callbacks = this._errbacks;
337
-
338
- if (!callbacks) return;
339
-
340
- var callback;
341
- while (callback = callbacks.shift())
342
- callback[0].apply(callback[1], this._deferredArgs);
727
+ this._reject(value);
728
+ else
729
+ delete this._promise;
343
730
  }
344
731
  };
345
732
 
346
-
347
733
  Faye.Publisher = {
348
734
  countListeners: function(eventType) {
349
- if (!this._subscribers || !this._subscribers[eventType]) return 0;
350
- return this._subscribers[eventType].length;
735
+ return this.listeners(eventType).length;
351
736
  },
352
737
 
353
738
  bind: function(eventType, listener, context) {
354
- this._subscribers = this._subscribers || {};
355
- var list = this._subscribers[eventType] = this._subscribers[eventType] || [];
356
- list.push([listener, context]);
357
- },
358
-
359
- unbind: function(eventType, listener, context) {
360
- if (!this._subscribers || !this._subscribers[eventType]) return;
361
-
362
- if (!listener) {
363
- delete this._subscribers[eventType];
364
- return;
365
- }
366
- var list = this._subscribers[eventType],
367
- i = list.length;
739
+ var slice = Array.prototype.slice,
740
+ handler = function() { listener.apply(context, slice.call(arguments)) };
368
741
 
369
- while (i--) {
370
- if (listener !== list[i][0]) continue;
371
- if (context && list[i][1] !== context) continue;
372
- list.splice(i,1);
373
- }
742
+ this._listeners = this._listeners || [];
743
+ this._listeners.push([eventType, listener, context, handler]);
744
+ return this.on(eventType, handler);
374
745
  },
375
746
 
376
- trigger: function() {
377
- var args = Array.prototype.slice.call(arguments),
378
- eventType = args.shift();
379
-
380
- if (!this._subscribers || !this._subscribers[eventType]) return;
381
-
382
- var listeners = this._subscribers[eventType].slice(),
383
- listener;
384
-
385
- for (var i = 0, n = listeners.length; i < n; i++) {
386
- listener = listeners[i];
387
- listener[0].apply(listener[1], args);
747
+ unbind: function(eventType, listener, context) {
748
+ this._listeners = this._listeners || [];
749
+ var n = this._listeners.length, tuple;
750
+
751
+ while (n--) {
752
+ tuple = this._listeners[n];
753
+ if (tuple[0] !== eventType) continue;
754
+ if (listener && (tuple[1] !== listener || tuple[2] !== context)) continue;
755
+ this._listeners.splice(n, 1);
756
+ this.removeListener(eventType, tuple[3]);
388
757
  }
389
758
  }
390
759
  };
391
760
 
761
+ Faye.extend(Faye.Publisher, Faye.EventEmitter.prototype);
762
+ Faye.Publisher.trigger = Faye.Publisher.emit;
392
763
 
393
764
  Faye.Timeouts = {
394
765
  addTimeout: function(name, delay, callback, context) {
@@ -410,26 +781,21 @@ Faye.Timeouts = {
410
781
  }
411
782
  };
412
783
 
413
-
414
784
  Faye.Logging = {
415
785
  LOG_LEVELS: {
786
+ fatal: 4,
416
787
  error: 3,
417
788
  warn: 2,
418
789
  info: 1,
419
790
  debug: 0
420
791
  },
421
792
 
422
- logLevel: 'error',
423
-
424
- log: function(messageArgs, level) {
793
+ writeLog: function(messageArgs, level) {
425
794
  if (!Faye.logger) return;
426
795
 
427
- var levels = Faye.Logging.LOG_LEVELS;
428
- if (levels[Faye.Logging.logLevel] > levels[level]) return;
429
-
430
796
  var messageArgs = Array.prototype.slice.apply(messageArgs),
431
- banner = ' [' + level.toUpperCase() + '] [Faye',
432
- klass = this.className,
797
+ banner = '[Faye',
798
+ klass = this.className,
433
799
 
434
800
  message = messageArgs.shift().replace(/\?/g, function() {
435
801
  try {
@@ -447,7 +813,10 @@ Faye.Logging = {
447
813
  if (klass) banner += '.' + klass;
448
814
  banner += '] ';
449
815
 
450
- Faye.logger(Faye.timestamp() + banner + message);
816
+ if (typeof Faye.logger[level] === 'function')
817
+ Faye.logger[level](banner + message);
818
+ else if (typeof Faye.logger === 'function')
819
+ Faye.logger(banner + message);
451
820
  }
452
821
  };
453
822
 
@@ -455,61 +824,18 @@ Faye.Logging = {
455
824
  for (var key in Faye.Logging.LOG_LEVELS)
456
825
  (function(level, value) {
457
826
  Faye.Logging[level] = function() {
458
- this.log(arguments, level);
827
+ this.writeLog(arguments, level);
459
828
  };
460
829
  })(key, Faye.Logging.LOG_LEVELS[key]);
461
830
  })();
462
831
 
463
-
464
832
  Faye.Grammar = {
465
-
466
- LOWALPHA: /^[a-z]$/,
467
-
468
- UPALPHA: /^[A-Z]$/,
469
-
470
- ALPHA: /^([a-z]|[A-Z])$/,
471
-
472
- DIGIT: /^[0-9]$/,
473
-
474
- ALPHANUM: /^(([a-z]|[A-Z])|[0-9])$/,
475
-
476
- MARK: /^(\-|\_|\!|\~|\(|\)|\$|\@)$/,
477
-
478
- STRING: /^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,
479
-
480
- TOKEN: /^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,
481
-
482
- INTEGER: /^([0-9])+$/,
483
-
484
- CHANNEL_SEGMENT: /^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,
485
-
486
- CHANNEL_SEGMENTS: /^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,
487
-
488
833
  CHANNEL_NAME: /^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,
489
-
490
- WILD_CARD: /^\*{1,2}$/,
491
-
492
- CHANNEL_PATTERN: /^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,
493
-
494
- VERSION_ELEMENT: /^(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*$/,
495
-
496
- VERSION: /^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/,
497
-
498
- CLIENT_ID: /^((([a-z]|[A-Z])|[0-9]))+$/,
499
-
500
- ID: /^((([a-z]|[A-Z])|[0-9]))+$/,
501
-
502
- ERROR_MESSAGE: /^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,
503
-
504
- ERROR_ARGS: /^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*$/,
505
-
506
- ERROR_CODE: /^[0-9][0-9][0-9]$/,
507
-
508
- ERROR: /^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/
509
-
834
+ CHANNEL_PATTERN: /^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,
835
+ ERROR: /^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/,
836
+ VERSION: /^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/
510
837
  };
511
838
 
512
-
513
839
  Faye.Extensible = {
514
840
  addExtension: function(extension) {
515
841
  this._extensions = this._extensions || [];
@@ -527,7 +853,7 @@ Faye.Extensible = {
527
853
  }
528
854
  },
529
855
 
530
- pipeThroughExtensions: function(stage, message, callback, context) {
856
+ pipeThroughExtensions: function(stage, message, request, callback, context) {
531
857
  this.debug('Passing through ? extensions: ?', stage, message);
532
858
 
533
859
  if (!this._extensions) return callback.call(context, message);
@@ -539,8 +865,11 @@ Faye.Extensible = {
539
865
  var extension = extensions.shift();
540
866
  if (!extension) return callback.call(context, message);
541
867
 
542
- if (extension[stage]) extension[stage](message, pipe);
543
- else pipe(message);
868
+ var fn = extension[stage];
869
+ if (!fn) return pipe(message);
870
+
871
+ if (fn.length >= 3) extension[stage](message, request, pipe);
872
+ else extension[stage](message, pipe);
544
873
  };
545
874
  pipe(message);
546
875
  }
@@ -673,9 +1002,18 @@ Faye.extend(Faye.Channel, {
673
1002
  })
674
1003
  });
675
1004
 
1005
+ Faye.Envelope = Faye.Class({
1006
+ initialize: function(message, timeout) {
1007
+ this.id = message.id;
1008
+ this.message = message;
676
1009
 
677
- Faye.Publication = Faye.Class(Faye.Deferrable);
1010
+ if (timeout !== undefined) this.timeout(timeout / 1000, false);
1011
+ }
1012
+ });
678
1013
 
1014
+ Faye.extend(Faye.Envelope.prototype, Faye.Deferrable);
1015
+
1016
+ Faye.Publication = Faye.Class(Faye.Deferrable);
679
1017
 
680
1018
  Faye.Subscription = Faye.Class({
681
1019
  initialize: function(client, channels, callback, context) {
@@ -699,7 +1037,6 @@ Faye.Subscription = Faye.Class({
699
1037
 
700
1038
  Faye.extend(Faye.Subscription.prototype, Faye.Deferrable);
701
1039
 
702
-
703
1040
  Faye.Client = Faye.Class({
704
1041
  UNCONNECTED: 1,
705
1042
  CONNECTING: 2,
@@ -710,23 +1047,30 @@ Faye.Client = Faye.Class({
710
1047
  RETRY: 'retry',
711
1048
  NONE: 'none',
712
1049
 
713
- CONNECTION_TIMEOUT: 60.0,
714
- DEFAULT_RETRY: 5.0,
1050
+ CONNECTION_TIMEOUT: 60,
1051
+ DEFAULT_RETRY: 5,
1052
+ MAX_REQUEST_SIZE: 2048,
715
1053
 
716
1054
  DEFAULT_ENDPOINT: '/bayeux',
717
- INTERVAL: 0.0,
1055
+ INTERVAL: 0,
718
1056
 
719
1057
  initialize: function(endpoint, options) {
720
1058
  this.info('New client created for ?', endpoint);
721
1059
 
722
1060
  this._options = options || {};
723
- this.endpoint = endpoint || this.DEFAULT_ENDPOINT;
1061
+ this.endpoint = Faye.URI.parse(endpoint || this.DEFAULT_ENDPOINT);
724
1062
  this.endpoints = this._options.endpoints || {};
725
1063
  this.transports = {};
726
- this._cookies = Faye.CookieJar && new Faye.CookieJar();
727
- this._headers = {};
1064
+ this.cookies = Faye.CookieJar && new Faye.CookieJar();
1065
+ this.headers = {};
1066
+ this.ca = this._options.ca;
728
1067
  this._disabled = [];
729
- this.retry = this._options.retry || this.DEFAULT_RETRY;
1068
+ this._retry = this._options.retry || this.DEFAULT_RETRY;
1069
+
1070
+ for (var key in this.endpoints)
1071
+ this.endpoints[key] = Faye.URI.parse(this.endpoints[key]);
1072
+
1073
+ this.maxRequestSize = this.MAX_REQUEST_SIZE;
730
1074
 
731
1075
  this._state = this.UNCONNECTED;
732
1076
  this._channels = new Faye.Channel.Set();
@@ -740,7 +1084,7 @@ Faye.Client = Faye.Class({
740
1084
  timeout: 1000 * (this._options.timeout || this.CONNECTION_TIMEOUT)
741
1085
  };
742
1086
 
743
- if (Faye.Event)
1087
+ if (Faye.Event && Faye.ENV.onbeforeunload !== undefined)
744
1088
  Faye.Event.on(Faye.ENV, 'beforeunload', function() {
745
1089
  if (Faye.indexOf(this._disabled, 'autodisconnect') < 0)
746
1090
  this.disconnect();
@@ -752,20 +1096,7 @@ Faye.Client = Faye.Class({
752
1096
  },
753
1097
 
754
1098
  setHeader: function(name, value) {
755
- this._headers[name] = value;
756
- },
757
-
758
- getClientId: function() {
759
- return this._clientId;
760
- },
761
-
762
- getState: function() {
763
- switch (this._state) {
764
- case this.UNCONNECTED: return 'UNCONNECTED';
765
- case this.CONNECTING: return 'CONNECTING';
766
- case this.CONNECTED: return 'CONNECTED';
767
- case this.DISCONNECTED: return 'DISCONNECTED';
768
- }
1099
+ this.headers[name] = value;
769
1100
  },
770
1101
 
771
1102
  // Request
@@ -794,12 +1125,12 @@ Faye.Client = Faye.Class({
794
1125
  this._state = this.CONNECTING;
795
1126
  var self = this;
796
1127
 
797
- this.info('Initiating handshake with ?', this.endpoint);
1128
+ this.info('Initiating handshake with ?', Faye.URI.stringify(this.endpoint));
798
1129
  this._selectTransport(Faye.MANDATORY_CONNECTION_TYPES);
799
1130
 
800
1131
  this._send({
801
- channel: Faye.Channel.HANDSHAKE,
802
- version: Faye.BAYEUX_VERSION,
1132
+ channel: Faye.Channel.HANDSHAKE,
1133
+ version: Faye.BAYEUX_VERSION,
803
1134
  supportedConnectionTypes: [this._transport.connectionType]
804
1135
 
805
1136
  }, function(response) {
@@ -813,7 +1144,7 @@ Faye.Client = Faye.Class({
813
1144
  this.info('Handshake successful: ?', this._clientId);
814
1145
 
815
1146
  this.subscribe(this._channels.getKeys(), true);
816
- if (callback) callback.call(context);
1147
+ if (callback) Faye.Promise.defer(function() { callback.call(context) });
817
1148
 
818
1149
  } else {
819
1150
  this.info('Handshake unsuccessful');
@@ -844,7 +1175,7 @@ Faye.Client = Faye.Class({
844
1175
 
845
1176
  this.info('Calling deferred actions for ?', this._clientId);
846
1177
  this.setDeferredStatus('succeeded');
847
- this.setDeferredStatus('deferred');
1178
+ this.setDeferredStatus('unknown');
848
1179
 
849
1180
  if (this._connectRequest) return;
850
1181
  this._connectRequest = true;
@@ -873,11 +1204,13 @@ Faye.Client = Faye.Class({
873
1204
  this.info('Disconnecting ?', this._clientId);
874
1205
 
875
1206
  this._send({
876
- channel: Faye.Channel.DISCONNECT,
877
- clientId: this._clientId
1207
+ channel: Faye.Channel.DISCONNECT,
1208
+ clientId: this._clientId
878
1209
 
879
1210
  }, function(response) {
880
- if (response.successful) this._transport.close();
1211
+ if (!response.successful) return;
1212
+ this._transport.close();
1213
+ delete this._transport;
881
1214
  }, this);
882
1215
 
883
1216
  this.info('Clearing channel listeners for ?', this._clientId);
@@ -983,9 +1316,10 @@ Faye.Client = Faye.Class({
983
1316
  this.info('Client ? queueing published message to ?: ?', this._clientId, channel, data);
984
1317
 
985
1318
  this._send({
986
- channel: channel,
987
- data: data,
988
- clientId: this._clientId
1319
+ channel: channel,
1320
+ data: data,
1321
+ clientId: this._clientId
1322
+
989
1323
  }, function(response) {
990
1324
  if (response.successful)
991
1325
  publication.setDeferredStatus('succeeded');
@@ -998,55 +1332,80 @@ Faye.Client = Faye.Class({
998
1332
  },
999
1333
 
1000
1334
  receiveMessage: function(message) {
1001
- this.pipeThroughExtensions('incoming', message, function(message) {
1335
+ var id = message.id, timeout, callback;
1336
+
1337
+ if (message.successful !== undefined) {
1338
+ callback = this._responseCallbacks[id];
1339
+ delete this._responseCallbacks[id];
1340
+ }
1341
+
1342
+ this.pipeThroughExtensions('incoming', message, null, function(message) {
1002
1343
  if (!message) return;
1003
1344
 
1004
1345
  if (message.advice) this._handleAdvice(message.advice);
1005
1346
  this._deliverMessage(message);
1006
1347
 
1007
- if (message.successful === undefined) return;
1348
+ if (callback) callback[0].call(callback[1], message);
1349
+ }, this);
1008
1350
 
1009
- var callback = this._responseCallbacks[message.id];
1010
- if (!callback) return;
1351
+ if (this._transportUp === true) return;
1352
+ this._transportUp = true;
1353
+ this.trigger('transport:up');
1354
+ },
1011
1355
 
1012
- delete this._responseCallbacks[message.id];
1013
- callback[0].call(callback[1], message);
1014
- }, this);
1356
+ messageError: function(messages, immediate) {
1357
+ var retry = this._retry,
1358
+ self = this,
1359
+ id, message, timeout;
1360
+
1361
+ for (var i = 0, n = messages.length; i < n; i++) {
1362
+ message = messages[i];
1363
+ id = message.id;
1364
+
1365
+ if (immediate)
1366
+ this._transportSend(message);
1367
+ else
1368
+ Faye.ENV.setTimeout(function() { self._transportSend(message) }, retry * 1000);
1369
+ }
1370
+
1371
+ if (immediate || this._transportUp === false) return;
1372
+ this._transportUp = false;
1373
+ this.trigger('transport:down');
1015
1374
  },
1016
1375
 
1017
1376
  _selectTransport: function(transportTypes) {
1018
1377
  Faye.Transport.get(this, transportTypes, this._disabled, function(transport) {
1019
- this.debug('Selected ? transport for ?', transport.connectionType, transport.endpoint);
1378
+ this.debug('Selected ? transport for ?', transport.connectionType, Faye.URI.stringify(transport.endpoint));
1020
1379
 
1021
1380
  if (transport === this._transport) return;
1022
1381
  if (this._transport) this._transport.close();
1023
1382
 
1024
1383
  this._transport = transport;
1025
- this._transport.cookies = this._cookies;
1026
- this._transport.headers = this._headers;
1027
-
1028
- transport.bind('down', function() {
1029
- if (this._transportUp !== undefined && !this._transportUp) return;
1030
- this._transportUp = false;
1031
- this.trigger('transport:down');
1032
- }, this);
1033
-
1034
- transport.bind('up', function() {
1035
- if (this._transportUp !== undefined && this._transportUp) return;
1036
- this._transportUp = true;
1037
- this.trigger('transport:up');
1038
- }, this);
1039
1384
  }, this);
1040
1385
  },
1041
1386
 
1042
1387
  _send: function(message, callback, context) {
1043
- message.id = this._generateMessageId();
1044
- if (callback) this._responseCallbacks[message.id] = [callback, context];
1388
+ if (!this._transport) return;
1389
+ message.id = message.id || this._generateMessageId();
1045
1390
 
1046
- this.pipeThroughExtensions('outgoing', message, function(message) {
1391
+ this.pipeThroughExtensions('outgoing', message, null, function(message) {
1047
1392
  if (!message) return;
1048
- this._transport.send(message, this._advice.timeout / 1000);
1393
+ if (callback) this._responseCallbacks[message.id] = [callback, context];
1394
+ this._transportSend(message);
1395
+ }, this);
1396
+ },
1397
+
1398
+ _transportSend: function(message) {
1399
+ if (!this._transport) return;
1400
+
1401
+ var timeout = 1.2 * (this._advice.timeout || this._retry * 1000),
1402
+ envelope = new Faye.Envelope(message, timeout);
1403
+
1404
+ envelope.errback(function(immediate) {
1405
+ this.messageError([message], immediate);
1049
1406
  }, this);
1407
+
1408
+ this._transport.send(envelope);
1050
1409
  },
1051
1410
 
1052
1411
  _generateMessageId: function() {
@@ -1071,14 +1430,11 @@ Faye.Client = Faye.Class({
1071
1430
  this._channels.distributeMessage(message);
1072
1431
  },
1073
1432
 
1074
- _teardownConnection: function() {
1075
- if (!this._connectRequest) return;
1076
- this._connectRequest = null;
1077
- this.info('Closed connection for ?', this._clientId);
1078
- },
1079
-
1080
1433
  _cycleConnection: function() {
1081
- this._teardownConnection();
1434
+ if (this._connectRequest) {
1435
+ this._connectRequest = null;
1436
+ this.info('Closed connection for ?', this._clientId);
1437
+ }
1082
1438
  var self = this;
1083
1439
  Faye.ENV.setTimeout(function() { self.connect() }, this._advice.interval);
1084
1440
  }
@@ -1089,9 +1445,8 @@ Faye.extend(Faye.Client.prototype, Faye.Publisher);
1089
1445
  Faye.extend(Faye.Client.prototype, Faye.Logging);
1090
1446
  Faye.extend(Faye.Client.prototype, Faye.Extensible);
1091
1447
 
1092
-
1093
1448
  Faye.Transport = Faye.extend(Faye.Class({
1094
- MAX_DELAY: 0.0,
1449
+ MAX_DELAY: 0,
1095
1450
  batching: true,
1096
1451
 
1097
1452
  initialize: function(client, endpoint) {
@@ -1102,14 +1457,19 @@ Faye.Transport = Faye.extend(Faye.Class({
1102
1457
 
1103
1458
  close: function() {},
1104
1459
 
1105
- send: function(message, timeout) {
1460
+ encode: function(envelopes) {
1461
+ return '';
1462
+ },
1463
+
1464
+ send: function(envelope) {
1465
+ var message = envelope.message;
1466
+
1106
1467
  this.debug('Client ? sending message to ?: ?',
1107
- this._client._clientId, this.endpoint, message);
1468
+ this._client._clientId, Faye.URI.stringify(this.endpoint), message);
1108
1469
 
1109
- if (!this.batching) return this.request([message], timeout);
1470
+ if (!this.batching) return this.request([envelope]);
1110
1471
 
1111
- this._outbox.push(message);
1112
- this._timeout = timeout;
1472
+ this._outbox.push(envelope);
1113
1473
 
1114
1474
  if (message.channel === Faye.Channel.HANDSHAKE)
1115
1475
  return this.addTimeout('publish', 0.01, this.flush, this);
@@ -1117,9 +1477,7 @@ Faye.Transport = Faye.extend(Faye.Class({
1117
1477
  if (message.channel === Faye.Channel.CONNECT)
1118
1478
  this._connectMessage = message;
1119
1479
 
1120
- if (this.shouldFlush && this.shouldFlush(this._outbox))
1121
- return this.flush();
1122
-
1480
+ this.flushLargeBatch();
1123
1481
  this.addTimeout('publish', this.MAX_DELAY, this.flush, this);
1124
1482
  },
1125
1483
 
@@ -1129,36 +1487,62 @@ Faye.Transport = Faye.extend(Faye.Class({
1129
1487
  if (this._outbox.length > 1 && this._connectMessage)
1130
1488
  this._connectMessage.advice = {timeout: 0};
1131
1489
 
1132
- this.request(this._outbox, this._timeout);
1490
+ this.request(this._outbox);
1133
1491
 
1134
1492
  this._connectMessage = null;
1135
1493
  this._outbox = [];
1136
1494
  },
1137
1495
 
1138
- receive: function(responses) {
1496
+ flushLargeBatch: function() {
1497
+ var string = this.encode(this._outbox);
1498
+ if (string.length < this._client.maxRequestSize) return;
1499
+ var last = this._outbox.pop();
1500
+ this.flush();
1501
+ if (last) this._outbox.push(last);
1502
+ },
1503
+
1504
+ receive: function(envelopes, responses) {
1505
+ var n = envelopes.length;
1506
+ while (n--) envelopes[n].setDeferredStatus('succeeded');
1507
+
1508
+ responses = [].concat(responses);
1509
+
1139
1510
  this.debug('Client ? received from ?: ?',
1140
- this._client._clientId, this.endpoint, responses);
1511
+ this._client._clientId, Faye.URI.stringify(this.endpoint), responses);
1141
1512
 
1142
- for (var i = 0, n = responses.length; i < n; i++) {
1513
+ for (var i = 0, n = responses.length; i < n; i++)
1143
1514
  this._client.receiveMessage(responses[i]);
1144
- }
1145
1515
  },
1146
1516
 
1147
- retry: function(message, timeout) {
1148
- var called = false,
1149
- retry = this._client.retry * 1000,
1150
- self = this;
1517
+ handleError: function(envelopes, immediate) {
1518
+ var n = envelopes.length;
1519
+ while (n--) envelopes[n].setDeferredStatus('failed', immediate);
1520
+ },
1151
1521
 
1152
- return function() {
1153
- if (called) return;
1154
- called = true;
1155
- Faye.ENV.setTimeout(function() { self.request(message, timeout) }, retry);
1156
- };
1522
+ _getCookies: function() {
1523
+ var cookies = this._client.cookies;
1524
+ if (!cookies) return '';
1525
+
1526
+ return cookies.getCookies({
1527
+ domain: this.endpoint.hostname,
1528
+ path: this.endpoint.path,
1529
+ secure: this.endpoint.protocol === 'https:'
1530
+ }).toValueString();
1531
+ },
1532
+
1533
+ _storeCookies: function(setCookie) {
1534
+ if (!setCookie || !this._client.cookies) return;
1535
+ setCookie = [].concat(setCookie);
1536
+ var cookie;
1537
+
1538
+ for (var i = 0, n = setCookie.length; i < n; i++) {
1539
+ cookie = this._client.cookies.setCookie(setCookie[i]);
1540
+ cookie = cookie[0] || cookie;
1541
+ cookie.domain = cookie.domain || this.endpoint.hostname;
1542
+ }
1157
1543
  }
1158
1544
 
1159
1545
  }), {
1160
- MAX_URL_LENGTH: 2048,
1161
-
1162
1546
  get: function(client, allowed, disabled, callback, context) {
1163
1547
  var endpoint = client.endpoint;
1164
1548
 
@@ -1180,7 +1564,7 @@ Faye.Transport = Faye.extend(Faye.Class({
1180
1564
  callback.call(context, transport);
1181
1565
  });
1182
1566
  }, function() {
1183
- throw new Error('Could not find a usable connection type for ' + endpoint);
1567
+ throw new Error('Could not find a usable connection type for ' + Faye.URI.stringify(endpoint));
1184
1568
  });
1185
1569
  },
1186
1570
 
@@ -1193,10 +1577,8 @@ Faye.Transport = Faye.extend(Faye.Class({
1193
1577
  });
1194
1578
 
1195
1579
  Faye.extend(Faye.Transport.prototype, Faye.Logging);
1196
- Faye.extend(Faye.Transport.prototype, Faye.Publisher);
1197
1580
  Faye.extend(Faye.Transport.prototype, Faye.Timeouts);
1198
1581
 
1199
-
1200
1582
  Faye.Event = {
1201
1583
  _registry: [],
1202
1584
 
@@ -1239,91 +1621,11 @@ Faye.Event = {
1239
1621
  }
1240
1622
  };
1241
1623
 
1242
- Faye.Event.on(Faye.ENV, 'unload', Faye.Event.detach, Faye.Event);
1243
-
1244
-
1245
- Faye.URI = Faye.extend(Faye.Class({
1246
- queryString: function() {
1247
- var pairs = [];
1248
- for (var key in this.params) {
1249
- if (!this.params.hasOwnProperty(key)) continue;
1250
- pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(this.params[key]));
1251
- }
1252
- return pairs.join('&');
1253
- },
1254
-
1255
- isSameOrigin: function() {
1256
- var host = Faye.URI.parse(Faye.ENV.location.href, false);
1257
-
1258
- var external = (host.hostname !== this.hostname) ||
1259
- (host.port !== this.port) ||
1260
- (host.protocol !== this.protocol);
1261
-
1262
- return !external;
1263
- },
1264
-
1265
- toURL: function() {
1266
- var query = this.queryString();
1267
- return this.protocol + '//' + this.hostname + (this.port ? ':' + this.port : '') +
1268
- this.pathname + (query ? '?' + query : '') + this.hash;
1269
- }
1270
- }), {
1271
- parse: function(url, params) {
1272
- if (typeof url !== 'string') return url;
1273
- var uri = new this(), parts;
1274
-
1275
- var consume = function(name, pattern, infer) {
1276
- url = url.replace(pattern, function(match) {
1277
- uri[name] = match;
1278
- return '';
1279
- });
1280
- if (uri[name] === undefined)
1281
- uri[name] = infer ? Faye.ENV.location[name] : '';
1282
- };
1283
-
1284
- consume('protocol', /^https?\:/, true);
1285
- consume('host', /^\/\/[^\/]+/, true);
1286
-
1287
- if (!/^\//.test(url)) url = Faye.ENV.location.pathname.replace(/[^\/]*$/, '') + url;
1288
- consume('pathname', /^\/[^\?#]*/);
1289
- consume('search', /^\?[^#]*/);
1290
- consume('hash', /^#.*/);
1291
-
1292
- if (/^\/\//.test(uri.host)) {
1293
- uri.host = uri.host.substr(2);
1294
- parts = uri.host.split(':');
1295
- uri.hostname = parts[0];
1296
- uri.port = parts[1] || '';
1297
- } else {
1298
- uri.hostname = Faye.ENV.location.hostname;
1299
- uri.port = Faye.ENV.location.port;
1300
- }
1301
-
1302
- if (params === false) {
1303
- uri.params = {};
1304
- } else {
1305
- var query = uri.search.replace(/^\?/, ''),
1306
- pairs = query ? query.split('&') : [],
1307
- n = pairs.length,
1308
- data = {};
1309
-
1310
- while (n--) {
1311
- parts = pairs[n].split('=');
1312
- data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');
1313
- }
1314
- if (typeof params === 'object') Faye.extend(data, params);
1315
-
1316
- uri.params = data;
1317
- }
1318
-
1319
- return uri;
1320
- }
1321
- });
1322
-
1624
+ if (Faye.ENV.onunload !== undefined) Faye.Event.on(Faye.ENV, 'unload', Faye.Event.detach, Faye.Event);
1323
1625
 
1324
1626
  /*
1325
- http://www.JSON.org/json2.js
1326
- 2009-04-16
1627
+ json2.js
1628
+ 2013-05-26
1327
1629
 
1328
1630
  Public Domain.
1329
1631
 
@@ -1331,6 +1633,14 @@ Faye.URI = Faye.extend(Faye.Class({
1331
1633
 
1332
1634
  See http://www.JSON.org/js.html
1333
1635
 
1636
+
1637
+ This code should be minified before deployment.
1638
+ See http://javascript.crockford.com/jsmin.html
1639
+
1640
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
1641
+ NOT CONTROL.
1642
+
1643
+
1334
1644
  This file creates a global JSON object containing two methods: stringify
1335
1645
  and parse.
1336
1646
 
@@ -1356,7 +1666,7 @@ Faye.URI = Faye.extend(Faye.Class({
1356
1666
  value represented by the name/value pair that should be serialized,
1357
1667
  or undefined if nothing should be serialized. The toJSON method
1358
1668
  will be passed the key associated with the value, and this will be
1359
- bound to the object holding the key.
1669
+ bound to the value
1360
1670
 
1361
1671
  For example, this would serialize Dates as ISO strings.
1362
1672
 
@@ -1459,17 +1769,9 @@ Faye.URI = Faye.extend(Faye.Class({
1459
1769
 
1460
1770
  This is a reference implementation. You are free to copy, modify, or
1461
1771
  redistribute.
1462
-
1463
- This code should be minified before deployment.
1464
- See http://javascript.crockford.com/jsmin.html
1465
-
1466
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
1467
- NOT CONTROL.
1468
1772
  */
1469
1773
 
1470
- /*jslint evil: true */
1471
-
1472
- /*global JSON */
1774
+ /*jslint evil: true, regexp: true */
1473
1775
 
1474
1776
  /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
1475
1777
  call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
@@ -1478,13 +1780,16 @@ Faye.URI = Faye.extend(Faye.Class({
1478
1780
  test, toJSON, toString, valueOf
1479
1781
  */
1480
1782
 
1783
+
1481
1784
  // Create a JSON object only if one does not already exist. We create the
1482
1785
  // methods in a closure to avoid creating global variables.
1483
1786
 
1484
- if (!this.JSON) {
1787
+ if (typeof JSON !== 'object') {
1485
1788
  JSON = {};
1486
1789
  }
1790
+
1487
1791
  (function () {
1792
+ 'use strict';
1488
1793
 
1489
1794
  function f(n) {
1490
1795
  // Format integers to have at least two digits.
@@ -1493,21 +1798,23 @@ if (!this.JSON) {
1493
1798
 
1494
1799
  if (typeof Date.prototype.toJSON !== 'function') {
1495
1800
 
1496
- Date.prototype.toJSON = function (key) {
1801
+ Date.prototype.toJSON = function () {
1497
1802
 
1498
- return this.getUTCFullYear() + '-' +
1499
- f(this.getUTCMonth() + 1) + '-' +
1500
- f(this.getUTCDate()) + 'T' +
1501
- f(this.getUTCHours()) + ':' +
1502
- f(this.getUTCMinutes()) + ':' +
1503
- f(this.getUTCSeconds()) + 'Z';
1803
+ return isFinite(this.valueOf())
1804
+ ? this.getUTCFullYear() + '-' +
1805
+ f(this.getUTCMonth() + 1) + '-' +
1806
+ f(this.getUTCDate()) + 'T' +
1807
+ f(this.getUTCHours()) + ':' +
1808
+ f(this.getUTCMinutes()) + ':' +
1809
+ f(this.getUTCSeconds()) + 'Z'
1810
+ : null;
1504
1811
  };
1505
1812
 
1506
- String.prototype.toJSON =
1507
- Number.prototype.toJSON =
1508
- Boolean.prototype.toJSON = function (key) {
1509
- return this.valueOf();
1510
- };
1813
+ String.prototype.toJSON =
1814
+ Number.prototype.toJSON =
1815
+ Boolean.prototype.toJSON = function () {
1816
+ return this.valueOf();
1817
+ };
1511
1818
  }
1512
1819
 
1513
1820
  var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
@@ -1534,13 +1841,12 @@ if (!this.JSON) {
1534
1841
  // sequences.
1535
1842
 
1536
1843
  escapable.lastIndex = 0;
1537
- return escapable.test(string) ?
1538
- '"' + string.replace(escapable, function (a) {
1539
- var c = meta[a];
1540
- return typeof c === 'string' ? c :
1541
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
1542
- }) + '"' :
1543
- '"' + string + '"';
1844
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
1845
+ var c = meta[a];
1846
+ return typeof c === 'string'
1847
+ ? c
1848
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
1849
+ }) + '"' : '"' + string + '"';
1544
1850
  }
1545
1851
 
1546
1852
 
@@ -1623,11 +1929,11 @@ if (!this.JSON) {
1623
1929
  // Join all of the elements together, separated with commas, and wrap them in
1624
1930
  // brackets.
1625
1931
 
1626
- v = partial.length === 0 ? '[]' :
1627
- gap ? '[\n' + gap +
1628
- partial.join(',\n' + gap) + '\n' +
1629
- mind + ']' :
1630
- '[' + partial.join(',') + ']';
1932
+ v = partial.length === 0
1933
+ ? '[]'
1934
+ : gap
1935
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
1936
+ : '[' + partial.join(',') + ']';
1631
1937
  gap = mind;
1632
1938
  return v;
1633
1939
  }
@@ -1637,8 +1943,8 @@ if (!this.JSON) {
1637
1943
  if (rep && typeof rep === 'object') {
1638
1944
  length = rep.length;
1639
1945
  for (i = 0; i < length; i += 1) {
1640
- k = rep[i];
1641
- if (typeof k === 'string') {
1946
+ if (typeof rep[i] === 'string') {
1947
+ k = rep[i];
1642
1948
  v = str(k, value);
1643
1949
  if (v) {
1644
1950
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -1650,7 +1956,7 @@ if (!this.JSON) {
1650
1956
  // Otherwise, iterate through all of the keys in the object.
1651
1957
 
1652
1958
  for (k in value) {
1653
- if (Object.hasOwnProperty.call(value, k)) {
1959
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
1654
1960
  v = str(k, value);
1655
1961
  if (v) {
1656
1962
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -1662,9 +1968,11 @@ if (!this.JSON) {
1662
1968
  // Join all of the member texts together, separated with commas,
1663
1969
  // and wrap them in braces.
1664
1970
 
1665
- v = partial.length === 0 ? '{}' :
1666
- gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
1667
- mind + '}' : '{' + partial.join(',') + '}';
1971
+ v = partial.length === 0
1972
+ ? '{}'
1973
+ : gap
1974
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
1975
+ : '{' + partial.join(',') + '}';
1668
1976
  gap = mind;
1669
1977
  return v;
1670
1978
  }
@@ -1672,10 +1980,7 @@ if (!this.JSON) {
1672
1980
 
1673
1981
  // If the JSON object does not yet have a stringify method, give it one.
1674
1982
 
1675
- // NOTE we've hacked this to expose this method to Faye. We need to use this
1676
- // to avoid problems with buggy Firefox version and bad #toJSON implementations
1677
-
1678
- Faye.stringify = function (value, replacer, space) {
1983
+ Faye.stringify = function (value, replacer, space) {
1679
1984
 
1680
1985
  // The stringify method takes a value and an optional replacer, and an optional
1681
1986
  // space parameter, and returns a JSON text. The replacer can be a function
@@ -1683,45 +1988,44 @@ if (!this.JSON) {
1683
1988
  // A default replacer method can be provided. Use of the space parameter can
1684
1989
  // produce text that is more easily readable.
1685
1990
 
1686
- var i;
1687
- gap = '';
1688
- indent = '';
1991
+ var i;
1992
+ gap = '';
1993
+ indent = '';
1689
1994
 
1690
1995
  // If the space parameter is a number, make an indent string containing that
1691
1996
  // many spaces.
1692
1997
 
1693
- if (typeof space === 'number') {
1694
- for (i = 0; i < space; i += 1) {
1695
- indent += ' ';
1696
- }
1998
+ if (typeof space === 'number') {
1999
+ for (i = 0; i < space; i += 1) {
2000
+ indent += ' ';
2001
+ }
1697
2002
 
1698
2003
  // If the space parameter is a string, it will be used as the indent string.
1699
2004
 
1700
- } else if (typeof space === 'string') {
1701
- indent = space;
1702
- }
2005
+ } else if (typeof space === 'string') {
2006
+ indent = space;
2007
+ }
1703
2008
 
1704
2009
  // If there is a replacer, it must be a function or an array.
1705
2010
  // Otherwise, throw an error.
1706
2011
 
1707
- rep = replacer;
1708
- if (replacer && typeof replacer !== 'function' &&
1709
- (typeof replacer !== 'object' ||
1710
- typeof replacer.length !== 'number')) {
1711
- throw new Error('JSON.stringify');
1712
- }
2012
+ rep = replacer;
2013
+ if (replacer && typeof replacer !== 'function' &&
2014
+ (typeof replacer !== 'object' ||
2015
+ typeof replacer.length !== 'number')) {
2016
+ throw new Error('JSON.stringify');
2017
+ }
1713
2018
 
1714
2019
  // Make a fake root object containing our value under the key of ''.
1715
2020
  // Return the result of stringifying the value.
1716
2021
 
1717
- return str('', {'': value});
1718
- };
2022
+ return str('', {'': value});
2023
+ };
1719
2024
 
1720
2025
  if (typeof JSON.stringify !== 'function') {
1721
2026
  JSON.stringify = Faye.stringify;
1722
2027
  }
1723
2028
 
1724
-
1725
2029
  // If the JSON object does not yet have a parse method, give it one.
1726
2030
 
1727
2031
  if (typeof JSON.parse !== 'function') {
@@ -1740,7 +2044,7 @@ if (!this.JSON) {
1740
2044
  var k, v, value = holder[key];
1741
2045
  if (value && typeof value === 'object') {
1742
2046
  for (k in value) {
1743
- if (Object.hasOwnProperty.call(value, k)) {
2047
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
1744
2048
  v = walk(value, k);
1745
2049
  if (v !== undefined) {
1746
2050
  value[k] = v;
@@ -1758,6 +2062,7 @@ if (!this.JSON) {
1758
2062
  // Unicode characters with escape sequences. JavaScript handles many characters
1759
2063
  // incorrectly, either silently deleting them, or treating them as line endings.
1760
2064
 
2065
+ text = String(text);
1761
2066
  cx.lastIndex = 0;
1762
2067
  if (cx.test(text)) {
1763
2068
  text = text.replace(cx, function (a) {
@@ -1779,10 +2084,10 @@ if (!this.JSON) {
1779
2084
  // we look to see that the remaining characters are only whitespace or ']' or
1780
2085
  // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
1781
2086
 
1782
- if (/^[\],:{}\s]*$/.
1783
- test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
1784
- replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
1785
- replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
2087
+ if (/^[\],:{}\s]*$/
2088
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
2089
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
2090
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
1786
2091
 
1787
2092
  // In the third stage we use the eval function to compile the text into a
1788
2093
  // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
@@ -1794,8 +2099,9 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
1794
2099
  // In the optional fourth stage, we recursively walk the new structure, passing
1795
2100
  // each name/value pair to a reviver function for possible transformation.
1796
2101
 
1797
- return typeof reviver === 'function' ?
1798
- walk({'': j}, '') : j;
2102
+ return typeof reviver === 'function'
2103
+ ? walk({'': j}, '')
2104
+ : j;
1799
2105
  }
1800
2106
 
1801
2107
  // If the text is not JSON parseable, then a SyntaxError is thrown.
@@ -1805,7 +2111,6 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
1805
2111
  }
1806
2112
  }());
1807
2113
 
1808
-
1809
2114
  Faye.Transport.WebSocket = Faye.extend(Faye.Class(Faye.Transport, {
1810
2115
  UNCONNECTED: 1,
1811
2116
  CONNECTING: 2,
@@ -1819,99 +2124,122 @@ Faye.Transport.WebSocket = Faye.extend(Faye.Class(Faye.Transport, {
1819
2124
  this.connect();
1820
2125
  },
1821
2126
 
1822
- request: function(messages, timeout) {
1823
- if (messages.length === 0) return;
1824
- this._messages = this._messages || {};
1825
-
1826
- for (var i = 0, n = messages.length; i < n; i++) {
1827
- this._messages[messages[i].id] = messages[i];
1828
- }
1829
- this.callback(function(socket) { socket.send(Faye.toJSON(messages)) });
2127
+ request: function(envelopes) {
2128
+ this.callback(function(socket) {
2129
+ if (!socket) return;
2130
+ for (var i = 0, n = envelopes.length; i < n; i++) this._pending.add(envelopes[i]);
2131
+ var messages = Faye.map(envelopes, function(e) { return e.message });
2132
+ socket.send(Faye.toJSON(messages));
2133
+ }, this);
1830
2134
  this.connect();
1831
2135
  },
1832
2136
 
1833
- close: function() {
1834
- if (!this._socket) return;
1835
- this._socket.onclose = this._socket.onerror = null;
1836
- this._socket.close();
1837
- delete this._socket;
1838
- this.setDeferredStatus('deferred');
1839
- this._state = this.UNCONNECTED;
1840
- },
1841
-
1842
2137
  connect: function() {
1843
2138
  if (Faye.Transport.WebSocket._unloaded) return;
1844
2139
 
1845
2140
  this._state = this._state || this.UNCONNECTED;
1846
2141
  if (this._state !== this.UNCONNECTED) return;
1847
-
1848
2142
  this._state = this.CONNECTING;
1849
2143
 
1850
- var ws = Faye.Transport.WebSocket.getClass();
1851
- if (!ws) return this.setDeferredStatus('failed');
2144
+ var socket = this._createSocket();
2145
+ if (!socket) return this.setDeferredStatus('failed');
1852
2146
 
1853
- this._socket = new ws(Faye.Transport.WebSocket.getSocketUrl(this.endpoint));
1854
2147
  var self = this;
1855
2148
 
1856
- this._socket.onopen = function() {
2149
+ socket.onopen = function() {
2150
+ if (socket.headers) self._storeCookies(socket.headers['set-cookie']);
2151
+ self._socket = socket;
2152
+ self._pending = new Faye.Set();
1857
2153
  self._state = self.CONNECTED;
1858
2154
  self._everConnected = true;
1859
- self.setDeferredStatus('succeeded', self._socket);
1860
- self.trigger('up');
2155
+ self._ping();
2156
+ self.setDeferredStatus('succeeded', socket);
1861
2157
  };
1862
2158
 
1863
- this._socket.onmessage = function(event) {
1864
- var messages = JSON.parse(event.data);
2159
+ var closed = false;
2160
+ socket.onclose = socket.onerror = function() {
2161
+ if (closed) return;
2162
+ closed = true;
2163
+
2164
+ var wasConnected = (self._state === self.CONNECTED);
2165
+ socket.onopen = socket.onclose = socket.onerror = socket.onmessage = null;
2166
+
2167
+ delete self._socket;
2168
+ self._state = self.UNCONNECTED;
2169
+ self.removeTimeout('ping');
2170
+ self.setDeferredStatus('unknown');
2171
+
2172
+ var pending = self._pending ? self._pending.toArray() : [];
2173
+ delete self._pending;
2174
+
2175
+ if (wasConnected) {
2176
+ self.handleError(pending, true);
2177
+ } else if (self._everConnected) {
2178
+ self.handleError(pending);
2179
+ } else {
2180
+ self.setDeferredStatus('failed');
2181
+ }
2182
+ };
2183
+
2184
+ socket.onmessage = function(event) {
2185
+ var messages = JSON.parse(event.data),
2186
+ envelopes = [],
2187
+ envelope;
2188
+
1865
2189
  if (!messages) return;
1866
2190
  messages = [].concat(messages);
1867
2191
 
1868
2192
  for (var i = 0, n = messages.length; i < n; i++) {
1869
- delete self._messages[messages[i].id];
2193
+ if (messages[i].successful === undefined) continue;
2194
+ envelope = self._pending.remove(messages[i]);
2195
+ if (envelope) envelopes.push(envelope);
1870
2196
  }
1871
- self.receive(messages);
2197
+ self.receive(envelopes, messages);
1872
2198
  };
2199
+ },
1873
2200
 
1874
- this._socket.onclose = this._socket.onerror = function() {
1875
- var wasConnected = (self._state === self.CONNECTED);
1876
- self.setDeferredStatus('deferred');
1877
- self._state = self.UNCONNECTED;
2201
+ close: function() {
2202
+ if (!this._socket) return;
2203
+ this._socket.close();
2204
+ },
1878
2205
 
1879
- self.close();
2206
+ _createSocket: function() {
2207
+ var url = Faye.Transport.WebSocket.getSocketUrl(this.endpoint),
2208
+ options = {headers: Faye.copyObject(this._client.headers), ca: this._client.ca};
1880
2209
 
1881
- if (wasConnected) return self.resend();
1882
- if (!self._everConnected) return self.setDeferredStatus('failed');
2210
+ options.headers['Cookie'] = this._getCookies();
1883
2211
 
1884
- var retry = self._client.retry * 1000;
1885
- Faye.ENV.setTimeout(function() { self.connect() }, retry);
1886
- self.trigger('down');
1887
- };
2212
+ if (Faye.WebSocket) return new Faye.WebSocket.Client(url, [], options);
2213
+ if (Faye.ENV.MozWebSocket) return new MozWebSocket(url);
2214
+ if (Faye.ENV.WebSocket) return new WebSocket(url);
1888
2215
  },
1889
2216
 
1890
- resend: function() {
1891
- if (!this._messages) return;
1892
- var messages = Faye.map(this._messages, function(id, msg) { return msg });
1893
- this.request(messages);
2217
+ _ping: function() {
2218
+ if (!this._socket) return;
2219
+ this._socket.send('[]');
2220
+ this.addTimeout('ping', this._client._advice.timeout/2000, this._ping, this);
1894
2221
  }
2222
+
1895
2223
  }), {
1896
- getSocketUrl: function(endpoint) {
1897
- if (Faye.URI) endpoint = Faye.URI.parse(endpoint).toURL();
1898
- return endpoint.replace(/^http(s?):/ig, 'ws$1:');
2224
+ PROTOCOLS: {
2225
+ 'http:': 'ws:',
2226
+ 'https:': 'wss:'
1899
2227
  },
1900
2228
 
1901
- getClass: function() {
1902
- return (Faye.WebSocket && Faye.WebSocket.Client) ||
1903
- Faye.ENV.WebSocket ||
1904
- Faye.ENV.MozWebSocket;
2229
+ create: function(client, endpoint) {
2230
+ var sockets = client.transports.websocket = client.transports.websocket || {};
2231
+ sockets[endpoint.href] = sockets[endpoint.href] || new this(client, endpoint);
2232
+ return sockets[endpoint.href];
1905
2233
  },
1906
2234
 
1907
- isUsable: function(client, endpoint, callback, context) {
1908
- this.create(client, endpoint).isUsable(callback, context);
2235
+ getSocketUrl: function(endpoint) {
2236
+ endpoint = Faye.copyObject(endpoint);
2237
+ endpoint.protocol = this.PROTOCOLS[endpoint.protocol];
2238
+ return Faye.URI.stringify(endpoint);
1909
2239
  },
1910
2240
 
1911
- create: function(client, endpoint) {
1912
- var sockets = client.transports.websocket = client.transports.websocket || {};
1913
- sockets[endpoint] = sockets[endpoint] || new this(client, endpoint);
1914
- return sockets[endpoint];
2241
+ isUsable: function(client, endpoint, callback, context) {
2242
+ this.create(client, endpoint).isUsable(callback, context);
1915
2243
  }
1916
2244
  });
1917
2245
 
@@ -1923,7 +2251,6 @@ if (Faye.Event)
1923
2251
  Faye.Transport.WebSocket._unloaded = true;
1924
2252
  });
1925
2253
 
1926
-
1927
2254
  Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
1928
2255
  initialize: function(client, endpoint) {
1929
2256
  Faye.Transport.prototype.initialize.call(this, client, endpoint);
@@ -1931,18 +2258,20 @@ Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
1931
2258
 
1932
2259
  this._xhr = new Faye.Transport.XHR(client, endpoint);
1933
2260
 
1934
- var socket = new EventSource(endpoint + '/' + client.getClientId()),
2261
+ endpoint = Faye.copyObject(endpoint);
2262
+ endpoint.pathname += '/' + client._clientId;
2263
+
2264
+ var socket = new EventSource(Faye.URI.stringify(endpoint)),
1935
2265
  self = this;
1936
2266
 
1937
2267
  socket.onopen = function() {
1938
2268
  self._everConnected = true;
1939
2269
  self.setDeferredStatus('succeeded');
1940
- self.trigger('up');
1941
2270
  };
1942
2271
 
1943
2272
  socket.onerror = function() {
1944
2273
  if (self._everConnected) {
1945
- self.trigger('down');
2274
+ self._client.messageError([]);
1946
2275
  } else {
1947
2276
  self.setDeferredStatus('failed');
1948
2277
  socket.close();
@@ -1950,31 +2279,35 @@ Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
1950
2279
  };
1951
2280
 
1952
2281
  socket.onmessage = function(event) {
1953
- self.receive(JSON.parse(event.data));
1954
- self.trigger('up');
2282
+ self.receive([], JSON.parse(event.data));
1955
2283
  };
1956
2284
 
1957
2285
  this._socket = socket;
1958
2286
  },
1959
2287
 
2288
+ close: function() {
2289
+ if (!this._socket) return;
2290
+ this._socket.onopen = this._socket.onerror = this._socket.onmessage = null;
2291
+ this._socket.close();
2292
+ delete this._socket;
2293
+ },
2294
+
1960
2295
  isUsable: function(callback, context) {
1961
2296
  this.callback(function() { callback.call(context, true) });
1962
2297
  this.errback(function() { callback.call(context, false) });
1963
2298
  },
1964
2299
 
1965
- request: function(message, timeout) {
1966
- this._xhr.request(message, timeout);
2300
+ encode: function(envelopes) {
2301
+ return this._xhr.encode(envelopes);
1967
2302
  },
1968
2303
 
1969
- close: function() {
1970
- if (!this._socket) return;
1971
- this._socket.onerror = null;
1972
- this._socket.close();
1973
- delete this._socket;
2304
+ request: function(envelopes) {
2305
+ this._xhr.request(envelopes);
1974
2306
  }
2307
+
1975
2308
  }), {
1976
2309
  isUsable: function(client, endpoint, callback, context) {
1977
- var id = client.getClientId();
2310
+ var id = client._clientId;
1978
2311
  if (!id) return callback.call(context, false);
1979
2312
 
1980
2313
  Faye.Transport.XHR.isUsable(client, endpoint, function(usable) {
@@ -1984,34 +2317,38 @@ Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
1984
2317
  },
1985
2318
 
1986
2319
  create: function(client, endpoint) {
1987
- var sockets = client.transports.eventsource = client.transports.eventsource || {},
1988
- id = client.getClientId(),
1989
- endpoint = endpoint + '/' + (id || '');
2320
+ var sockets = client.transports.eventsource = client.transports.eventsource || {},
2321
+ id = client._clientId;
2322
+
2323
+ endpoint = Faye.copyObject(endpoint);
2324
+ endpoint.pathname += '/' + (id || '');
2325
+ var url = Faye.URI.stringify(endpoint);
1990
2326
 
1991
- sockets[endpoint] = sockets[endpoint] || new this(client, endpoint);
1992
- return sockets[endpoint];
2327
+ sockets[url] = sockets[url] || new this(client, endpoint);
2328
+ return sockets[url];
1993
2329
  }
1994
2330
  });
1995
2331
 
1996
2332
  Faye.extend(Faye.Transport.EventSource.prototype, Faye.Deferrable);
1997
2333
  Faye.Transport.register('eventsource', Faye.Transport.EventSource);
1998
2334
 
1999
-
2000
2335
  Faye.Transport.XHR = Faye.extend(Faye.Class(Faye.Transport, {
2001
- request: function(message, timeout) {
2002
- var retry = this.retry(message, timeout),
2003
- path = Faye.URI.parse(this.endpoint).pathname,
2004
- self = this,
2005
- xhr = Faye.ENV.ActiveXObject
2006
- ? new ActiveXObject("Microsoft.XMLHTTP")
2007
- : new XMLHttpRequest();
2336
+ encode: function(envelopes) {
2337
+ var messages = Faye.map(envelopes, function(e) { return e.message });
2338
+ return Faye.toJSON(messages);
2339
+ },
2340
+
2341
+ request: function(envelopes) {
2342
+ var path = this.endpoint.path,
2343
+ xhr = Faye.ENV.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(),
2344
+ self = this;
2008
2345
 
2009
2346
  xhr.open('POST', path, true);
2010
2347
  xhr.setRequestHeader('Content-Type', 'application/json');
2011
2348
  xhr.setRequestHeader('Pragma', 'no-cache');
2012
2349
  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
2013
2350
 
2014
- var headers = this.headers;
2351
+ var headers = this._client.headers;
2015
2352
  for (var key in headers) {
2016
2353
  if (!headers.hasOwnProperty(key)) continue;
2017
2354
  xhr.setRequestHeader(key, headers[key]);
@@ -2020,68 +2357,67 @@ Faye.Transport.XHR = Faye.extend(Faye.Class(Faye.Transport, {
2020
2357
  var abort = function() { xhr.abort() };
2021
2358
  Faye.Event.on(Faye.ENV, 'beforeunload', abort);
2022
2359
 
2023
- var cleanUp = function() {
2024
- Faye.Event.detach(Faye.ENV, 'beforeunload', abort);
2025
- xhr.onreadystatechange = function() {};
2026
- xhr = null;
2027
- };
2028
-
2029
2360
  xhr.onreadystatechange = function() {
2030
- if (xhr.readyState !== 4) return;
2361
+ if (!xhr || xhr.readyState !== 4) return;
2031
2362
 
2032
2363
  var parsedMessage = null,
2033
2364
  status = xhr.status,
2034
- successful = ((status >= 200 && status < 300) ||
2035
- status === 304 ||
2036
- status === 1223);
2037
-
2038
- if (!successful) {
2039
- cleanUp();
2040
- retry();
2041
- return self.trigger('down');
2042
- }
2365
+ text = xhr.responseText,
2366
+ successful = (status >= 200 && status < 300) || status === 304 || status === 1223;
2367
+
2368
+ Faye.Event.detach(Faye.ENV, 'beforeunload', abort);
2369
+ xhr.onreadystatechange = function() {};
2370
+ xhr = null;
2371
+
2372
+ if (!successful) return self.handleError(envelopes);
2043
2373
 
2044
2374
  try {
2045
- parsedMessage = JSON.parse(xhr.responseText);
2375
+ parsedMessage = JSON.parse(text);
2046
2376
  } catch (e) {}
2047
2377
 
2048
- cleanUp();
2049
-
2050
- if (parsedMessage) {
2051
- self.receive(parsedMessage);
2052
- self.trigger('up');
2053
- } else {
2054
- retry();
2055
- self.trigger('down');
2056
- }
2378
+ if (parsedMessage)
2379
+ self.receive(envelopes, parsedMessage);
2380
+ else
2381
+ self.handleError(envelopes);
2057
2382
  };
2058
2383
 
2059
- xhr.send(Faye.toJSON(message));
2384
+ xhr.send(this.encode(envelopes));
2060
2385
  }
2061
2386
  }), {
2062
2387
  isUsable: function(client, endpoint, callback, context) {
2063
- callback.call(context, Faye.URI.parse(endpoint).isSameOrigin());
2388
+ callback.call(context, Faye.URI.isSameOrigin(endpoint));
2064
2389
  }
2065
2390
  });
2066
2391
 
2067
2392
  Faye.Transport.register('long-polling', Faye.Transport.XHR);
2068
2393
 
2069
2394
  Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2070
- request: function(message, timeout) {
2395
+ encode: function(envelopes) {
2396
+ var messages = Faye.map(envelopes, function(e) { return e.message });
2397
+ return 'message=' + encodeURIComponent(Faye.toJSON(messages));
2398
+ },
2399
+
2400
+ request: function(envelopes) {
2071
2401
  var xhrClass = Faye.ENV.XDomainRequest ? XDomainRequest : XMLHttpRequest,
2072
2402
  xhr = new xhrClass(),
2073
- retry = this.retry(message, timeout),
2074
- self = this;
2403
+ headers = this._client.headers,
2404
+ self = this,
2405
+ key;
2406
+
2407
+ xhr.open('POST', Faye.URI.stringify(this.endpoint), true);
2075
2408
 
2076
- xhr.open('POST', this.endpoint, true);
2077
- if (xhr.setRequestHeader) xhr.setRequestHeader('Pragma', 'no-cache');
2409
+ if (xhr.setRequestHeader) {
2410
+ xhr.setRequestHeader('Pragma', 'no-cache');
2411
+ for (key in headers) {
2412
+ if (!headers.hasOwnProperty(key)) continue;
2413
+ xhr.setRequestHeader(key, headers[key]);
2414
+ }
2415
+ }
2078
2416
 
2079
2417
  var cleanUp = function() {
2080
2418
  if (!xhr) return false;
2081
2419
  xhr.onload = xhr.onerror = xhr.ontimeout = xhr.onprogress = null;
2082
2420
  xhr = null;
2083
- Faye.ENV.clearTimeout(timer);
2084
- return true;
2085
2421
  };
2086
2422
 
2087
2423
  xhr.onload = function() {
@@ -2092,35 +2428,27 @@ Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2092
2428
 
2093
2429
  cleanUp();
2094
2430
 
2095
- if (parsedMessage) {
2096
- self.receive(parsedMessage);
2097
- self.trigger('up');
2098
- } else {
2099
- retry();
2100
- self.trigger('down');
2101
- }
2431
+ if (parsedMessage)
2432
+ self.receive(envelopes, parsedMessage);
2433
+ else
2434
+ self.handleError(envelopes);
2102
2435
  };
2103
2436
 
2104
- var onerror = function() {
2437
+ xhr.onerror = xhr.ontimeout = function() {
2105
2438
  cleanUp();
2106
- retry();
2107
- self.trigger('down');
2439
+ self.handleError(envelopes);
2108
2440
  };
2109
- var timer = Faye.ENV.setTimeout(onerror, 1.5 * 1000 * timeout);
2110
- xhr.onerror = onerror;
2111
- xhr.ontimeout = onerror;
2112
2441
 
2113
2442
  xhr.onprogress = function() {};
2114
- xhr.send('message=' + encodeURIComponent(Faye.toJSON(message)));
2443
+ xhr.send(this.encode(envelopes));
2115
2444
  }
2116
2445
  }), {
2117
2446
  isUsable: function(client, endpoint, callback, context) {
2118
- if (Faye.URI.parse(endpoint).isSameOrigin())
2447
+ if (Faye.URI.isSameOrigin(endpoint))
2119
2448
  return callback.call(context, false);
2120
2449
 
2121
2450
  if (Faye.ENV.XDomainRequest)
2122
- return callback.call(context, Faye.URI.parse(endpoint).protocol ===
2123
- Faye.URI.parse(Faye.ENV.location).protocol);
2451
+ return callback.call(context, endpoint.protocol === Faye.ENV.location.protocol);
2124
2452
 
2125
2453
  if (Faye.ENV.XMLHttpRequest) {
2126
2454
  var xhr = new Faye.ENV.XMLHttpRequest();
@@ -2132,50 +2460,36 @@ Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2132
2460
 
2133
2461
  Faye.Transport.register('cross-origin-long-polling', Faye.Transport.CORS);
2134
2462
 
2135
-
2136
2463
  Faye.Transport.JSONP = Faye.extend(Faye.Class(Faye.Transport, {
2137
- shouldFlush: function(messages) {
2138
- var params = {
2139
- message: Faye.toJSON(messages),
2140
- jsonp: '__jsonp' + Faye.Transport.JSONP._cbCount + '__'
2141
- };
2142
- var location = Faye.URI.parse(this.endpoint, params).toURL();
2143
- return location.length >= Faye.Transport.MAX_URL_LENGTH;
2464
+ encode: function(envelopes) {
2465
+ var messages = Faye.map(envelopes, function(e) { return e.message });
2466
+ var url = Faye.copyObject(this.endpoint);
2467
+ url.query.message = Faye.toJSON(messages);
2468
+ url.query.jsonp = '__jsonp' + Faye.Transport.JSONP._cbCount + '__';
2469
+ return Faye.URI.stringify(url);
2144
2470
  },
2145
2471
 
2146
- request: function(messages, timeout) {
2147
- var params = {message: Faye.toJSON(messages)},
2472
+ request: function(envelopes) {
2473
+ var messages = Faye.map(envelopes, function(e) { return e.message }),
2148
2474
  head = document.getElementsByTagName('head')[0],
2149
2475
  script = document.createElement('script'),
2150
2476
  callbackName = Faye.Transport.JSONP.getCallbackName(),
2151
- location = Faye.URI.parse(this.endpoint, params),
2152
- retry = this.retry(messages, timeout),
2477
+ endpoint = Faye.copyObject(this.endpoint),
2153
2478
  self = this;
2154
2479
 
2155
- Faye.ENV[callbackName] = function(data) {
2156
- cleanUp();
2157
- self.receive(data);
2158
- self.trigger('up');
2159
- };
2160
-
2161
- var timer = Faye.ENV.setTimeout(function() {
2162
- cleanUp();
2163
- retry();
2164
- self.trigger('down');
2165
- }, 1.5 * 1000 * timeout);
2480
+ endpoint.query.message = Faye.toJSON(messages);
2481
+ endpoint.query.jsonp = callbackName;
2166
2482
 
2167
- var cleanUp = function() {
2483
+ Faye.ENV[callbackName] = function(data) {
2168
2484
  if (!Faye.ENV[callbackName]) return false;
2169
2485
  Faye.ENV[callbackName] = undefined;
2170
2486
  try { delete Faye.ENV[callbackName] } catch (e) {}
2171
- Faye.ENV.clearTimeout(timer);
2172
2487
  script.parentNode.removeChild(script);
2173
- return true;
2488
+ self.receive(envelopes, data);
2174
2489
  };
2175
2490
 
2176
- location.params.jsonp = callbackName;
2177
2491
  script.type = 'text/javascript';
2178
- script.src = location.toURL();
2492
+ script.src = Faye.URI.stringify(endpoint);
2179
2493
  head.appendChild(script);
2180
2494
  }
2181
2495
  }), {
@@ -2192,3 +2506,5 @@ Faye.Transport.JSONP = Faye.extend(Faye.Class(Faye.Transport, {
2192
2506
  });
2193
2507
 
2194
2508
  Faye.Transport.register('callback-polling', Faye.Transport.JSONP);
2509
+
2510
+ })();