faye 0.8.8 → 0.8.9

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 (67) hide show
  1. data/History.txt +16 -10
  2. data/README.rdoc +1 -1
  3. data/lib/faye-browser-min.js +1 -1
  4. data/lib/faye-browser-min.js.map +2 -2
  5. data/lib/faye-browser.js +302 -287
  6. data/lib/faye.rb +21 -21
  7. data/lib/faye/adapters/rack_adapter.rb +50 -48
  8. data/lib/faye/adapters/static_server.rb +22 -22
  9. data/lib/faye/engines/connection.rb +13 -13
  10. data/lib/faye/engines/memory.rb +21 -21
  11. data/lib/faye/engines/proxy.rb +23 -23
  12. data/lib/faye/error.rb +6 -6
  13. data/lib/faye/mixins/logging.rb +12 -12
  14. data/lib/faye/mixins/publisher.rb +6 -6
  15. data/lib/faye/mixins/timeouts.rb +1 -1
  16. data/lib/faye/protocol/channel.rb +24 -24
  17. data/lib/faye/protocol/client.rb +71 -73
  18. data/lib/faye/protocol/extensible.rb +7 -7
  19. data/lib/faye/protocol/grammar.rb +13 -13
  20. data/lib/faye/protocol/server.rb +57 -57
  21. data/lib/faye/protocol/socket.rb +4 -4
  22. data/lib/faye/protocol/subscription.rb +4 -4
  23. data/lib/faye/transport/http.rb +13 -13
  24. data/lib/faye/transport/local.rb +5 -5
  25. data/lib/faye/transport/transport.rb +25 -25
  26. data/lib/faye/transport/web_socket.rb +34 -30
  27. data/lib/faye/util/namespace.rb +4 -4
  28. data/spec/browser.html +5 -5
  29. data/spec/javascript/channel_spec.js +3 -3
  30. data/spec/javascript/client_spec.js +104 -98
  31. data/spec/javascript/engine/memory_spec.js +1 -1
  32. data/spec/javascript/engine_spec.js +70 -70
  33. data/spec/javascript/faye_spec.js +6 -6
  34. data/spec/javascript/grammar_spec.js +12 -12
  35. data/spec/javascript/node_adapter_spec.js +46 -46
  36. data/spec/javascript/publisher_spec.js +4 -4
  37. data/spec/javascript/server/connect_spec.js +21 -21
  38. data/spec/javascript/server/disconnect_spec.js +15 -15
  39. data/spec/javascript/server/extensions_spec.js +6 -6
  40. data/spec/javascript/server/handshake_spec.js +18 -18
  41. data/spec/javascript/server/integration_spec.js +23 -23
  42. data/spec/javascript/server/publish_spec.js +9 -9
  43. data/spec/javascript/server/subscribe_spec.js +30 -30
  44. data/spec/javascript/server/unsubscribe_spec.js +30 -30
  45. data/spec/javascript/server_spec.js +15 -15
  46. data/spec/javascript/transport_spec.js +32 -27
  47. data/spec/node.js +2 -2
  48. data/spec/ruby/channel_spec.rb +2 -2
  49. data/spec/ruby/client_spec.rb +100 -92
  50. data/spec/ruby/engine_examples.rb +51 -51
  51. data/spec/ruby/faye_spec.rb +5 -5
  52. data/spec/ruby/grammar_spec.rb +12 -12
  53. data/spec/ruby/publisher_spec.rb +4 -4
  54. data/spec/ruby/rack_adapter_spec.rb +34 -34
  55. data/spec/ruby/server/connect_spec.rb +22 -22
  56. data/spec/ruby/server/disconnect_spec.rb +16 -16
  57. data/spec/ruby/server/extensions_spec.rb +8 -8
  58. data/spec/ruby/server/handshake_spec.rb +20 -20
  59. data/spec/ruby/server/integration_spec.rb +22 -24
  60. data/spec/ruby/server/publish_spec.rb +9 -9
  61. data/spec/ruby/server/subscribe_spec.rb +31 -31
  62. data/spec/ruby/server/unsubscribe_spec.rb +31 -31
  63. data/spec/ruby/server_spec.rb +17 -17
  64. data/spec/ruby/transport_spec.rb +23 -23
  65. data/spec/testswarm +23 -10
  66. data/spec/thin_proxy.rb +5 -5
  67. metadata +90 -59
@@ -1,3 +1,19 @@
1
+ === 0.8.9 / 2013-02-26
2
+
3
+ * Specify ciphers for SSL on Node to mitigate the BEAST attack
4
+ * Mitigate increased risk of socket hang-up errors in Node v0.8.20
5
+ * Fix race condition when processing outgoing extensions in the Node server
6
+ * Fix problem loading the client script when using {mount: '/'}
7
+ * Clean up connection objects when a WebSocket is re-used with a new clientId
8
+ * All JavaScript code now runs in strict mode
9
+ * Select transport on handshake, instead of on client creation to allow time for disable() calls
10
+ * Do not speculatively open WebSocket/EventSource connections if they are disabled
11
+ * Gracefully handle WebSocket messages with no data on the client side
12
+ * Close and reconnect WebSocket when onerror is fired, not just when onclose is fired
13
+ * Fix problem with caching of EventSource connections with stale clientIds
14
+ * Don't parse query strings when checking if a URL is same-origin or not
15
+
16
+
1
17
  === 0.8.8 / 2013-01-10
2
18
 
3
19
  * Patch security hole allowing remote execution of arbitrary Server methods
@@ -40,7 +56,6 @@
40
56
 
41
57
 
42
58
  === 0.8.2 / 2012-04-12
43
- TestSwarm build: http://swarm.jcoglan.com/job/125/
44
59
 
45
60
  * Fix replacement of null with {} in copyObject()
46
61
  * Make EventSource transport trigger transport:up/down events
@@ -50,7 +65,6 @@ TestSwarm build: http://swarm.jcoglan.com/job/125/
50
65
 
51
66
 
52
67
  === 0.8.1 / 2012-03-15
53
- TestSwarm build: http://swarm.jcoglan.com/job/124/
54
68
 
55
69
  * Make Publisher#trigger safe for event listeners that modify the listener list
56
70
  * Make Server#subscribe return a response if the incoming message has an error
@@ -62,7 +76,6 @@ TestSwarm build: http://swarm.jcoglan.com/job/124/
62
76
 
63
77
 
64
78
  === 0.8.0 / 2012-02-26
65
- TestSwarm build: http://swarm.jcoglan.com/job/123/
66
79
 
67
80
  * Extract the Redis engine into a separate library, faye-redis
68
81
  * Stabilize and document the Engine API so others can write backends
@@ -85,7 +98,6 @@ TestSwarm build: http://swarm.jcoglan.com/job/123/
85
98
 
86
99
 
87
100
  === 0.7.0 / 2011-11-22
88
- TestSwarm build: http://swarm.jcoglan.com/job/107/
89
101
 
90
102
  * Provide an event API for monitoring engine events on the server side
91
103
  * Implement server-side WebSocket connections for improved latency
@@ -97,7 +109,6 @@ TestSwarm build: http://swarm.jcoglan.com/job/107/
97
109
 
98
110
 
99
111
  === 0.6.7 / 2011-10-20
100
- TestSwarm build: http://swarm.jcoglan.com/job/101/
101
112
 
102
113
  * Cache client script in memory and add ETag and Last-Modified headers
103
114
  * Fix bug in Node Redis engine where 'undefined' was used if no namespace given
@@ -117,7 +128,6 @@ TestSwarm build: http://swarm.jcoglan.com/job/101/
117
128
 
118
129
 
119
130
  === 0.6.5 / 2011-08-29
120
- TestSwarm build: http://swarm.jcoglan.com/job/99/
121
131
 
122
132
  * Fix UTF-8 encoding bugs in draft-75/76 and protocol-8 WebSocket parsers
123
133
  * Switch to streaming parser for WebSocket protocol-8
@@ -126,7 +136,6 @@ TestSwarm build: http://swarm.jcoglan.com/job/99/
126
136
 
127
137
 
128
138
  === 0.6.4 / 2011-08-18
129
- TestSwarm build: http://swarm.jcoglan.com/job/96/
130
139
 
131
140
  * Support WebSocket protocol used by Chrome 14 and Firefox 6
132
141
  * Fix handling of multibyte characters in WebSocket messages on Node
@@ -134,7 +143,6 @@ TestSwarm build: http://swarm.jcoglan.com/job/96/
134
143
 
135
144
 
136
145
  === 0.6.3 / 2011-07-10
137
- TestSwarm build: http://swarm.jcoglan.com/job/69/
138
146
 
139
147
  * Use sequential message IDs to reduce memory usage on the client side
140
148
  * Only send advice with handshake and connect responses
@@ -156,14 +164,12 @@ TestSwarm build: http://swarm.jcoglan.com/job/69/
156
164
 
157
165
 
158
166
  === 0.6.1 / 2011-06-06
159
- TestSwarm build: http://swarm.jcoglan.com/job/37/
160
167
 
161
168
  * Fix cross-origin-long-polling support in RackAdapter
162
169
  * Plug some potential memory leaks in Memory engine
163
170
 
164
171
 
165
172
  === 0.6.0 / 2011-05-21
166
- TestSwarm build: http://swarm.jcoglan.com/job/27/
167
173
 
168
174
  * Extract core logic into the Engine class to support swappable backends
169
175
  * Introduce a Redis-backed engine to support clustered web front-ends
@@ -62,7 +62,7 @@ should get you up and running:
62
62
 
63
63
  (The MIT License)
64
64
 
65
- Copyright (c) 2009-2012 James Coglan and contributors
65
+ Copyright (c) 2009-2013 James Coglan and contributors
66
66
 
67
67
  Permission is hereby granted, free of charge, to any person obtaining a copy of
68
68
  this software and associated documentation files (the 'Software'), to deal in
@@ -1,2 +1,2 @@
1
- var Faye=(typeof Faye==='object')?Faye:{};if(typeof window!=='undefined')window.Faye=Faye;Faye.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};Faye.extend(Faye,{VERSION:'0.8.8',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:(function(){return this})(),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 l=function(){if(k)return;k=true;while(i>0)j();k=false};var n=function(){i+=1;l()};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)}});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._w==='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._x=f},errback:function(a,b){if(!a)return;if(this._w==='failed')return a.apply(b,this._j);this._l=this._l||[];this._l.push([a,b])},setDeferredStatus:function(){if(this._x)Faye.ENV.clearTimeout(this._x);var a=Array.prototype.slice.call(arguments),b=a.shift(),d;this._w=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._3||!this._3[a])return 0;return this._3[a].length},bind:function(a,b,d){this._3=this._3||{};var f=this._3[a]=this._3[a]||[];f.push([b,d])},unbind:function(a,b,d){if(!this._3||!this._3[a])return;if(!b){delete this._3[a];return}var f=this._3[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._3||!this._3[b])return;var d=this._3[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._5=this._5||{};if(this._5.hasOwnProperty(a))return;var g=this;this._5[a]=Faye.ENV.setTimeout(function(){delete g._5[a];d.call(f)},1000*b)},removeTimeout:function(a){this._5=this._5||{};var b=this._5[a];if(!b)return;clearTimeout(b);delete this._5[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._6=this._6||[];this._6.push(a);if(a.added)a.added(this)},removeExtension:function(a){if(!this._6)return;var b=this._6.length;while(b--){if(this._6[b]!==a)continue;this._6.splice(b,1);if(a.removed)a.removed(this)}},pipeThroughExtensions:function(d,f,g,h){this.debug('Passing through ? extensions: ?',d,f);if(!this._6)return g.call(h,f);var i=this._6.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._7=a;this._2=b;this._m=d;this._n=f;this._y=false},cancel:function(){if(this._y)return;this._7.unsubscribe(this._2,this._m,this._n);this._y=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._E=Faye.CookieJar&&new Faye.CookieJar();this._z={};this._o=[];this.retry=this._f.retry||this.DEFAULT_RETRY;this._A(Faye.MANDATORY_CONNECTION_TYPES);this._1=this.UNCONNECTED;this._2=new Faye.Channel.Set();this._g=0;this._p={};this._8={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._z[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(f,g){if(this._8.reconnect===this.NONE)return;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var h=this;this.info('Initiating handshake with ?',this.endpoint);this._9({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:[this._a.connectionType]},function(b){if(b.successful){this._1=this.CONNECTED;this._0=b.clientId;var d=Faye.filter(b.supportedConnectionTypes,function(a){return Faye.indexOf(this._o,a)<0},this);this._A(d);this.info('Handshake successful: ?',this._0);this.subscribe(this._2.getKeys(),true);if(f)f.call(g)}else{this.info('Handshake unsuccessful');Faye.ENV.setTimeout(function(){h.handshake(f,g)},this._8.interval);this._1=this.UNCONNECTED}},this)},connect:function(a,b){if(this._8.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._9({channel:Faye.Channel.CONNECT,clientId:this._0,connectionType:this._a.connectionType},this._B,this)},disconnect:function(){if(this._1!==this.CONNECTED)return;this._1=this.DISCONNECTED;this.info('Disconnecting ?',this._0);this._9({channel:Faye.Channel.DISCONNECT,clientId:this._0},function(a){if(a.successful)this._a.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._9({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._9({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._9({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._F(a.advice);this._G(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)},_A:function(b){Faye.Transport.get(this,b,function(a){this.debug('Selected ? transport for ?',a.connectionType,a.endpoint);this._a=a;this._a.cookies=this._E;this._a.headers=this._z;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)},_9:function(b,d,f){b.id=this._H();if(d)this._p[b.id]=[d,f];this.pipeThroughExtensions('outgoing',b,function(a){if(!a)return;this._a.send(a,this._8.timeout/1000)},this)},_H:function(){this._g+=1;if(this._g>=Math.pow(2,32))this._g=0;return this._g.toString(36)},_F:function(a){Faye.extend(this._8,a);if(this._8.reconnect===this.HANDSHAKE&&this._1!==this.DISCONNECTED){this._1=this.UNCONNECTED;this._0=null;this._B()}},_G: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)},_I:function(){if(!this._q)return;this._q=null;this.info('Closed connection for ?',this._0)},_B:function(){this._I();var a=this;Faye.ENV.setTimeout(function(){a.connect()},this._8.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._7=a;this.endpoint=b;this._c=[]},close:function(){},send:function(a,b){this.debug('Client ? sending message to ?: ?',this._7._0,this.endpoint,a);if(!this.batching)return this.request([a],b);this._c.push(a);this._J=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._J);this._r=null;this._c=[]},receive:function(a){this.debug('Client ? received from ?: ?',this._7._0,this.endpoint,a);for(var b=0,d=a.length;b<d;b++){this._7.receiveMessage(a[b])}},retry:function(a,b){var d=false,f=this._7.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,l,n){var o=k.endpoint;if(j===undefined)j=this.supportedConnectionTypes();Faye.asyncEach(this._s,function(d,f){var g=d[0],h=d[1],i=k.endpoints[g]||o;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);l.call(n,b)})},function(){throw new Error('Could not find a usable connection type for '+o);})},register:function(a,b){this._s.push([a,b]);b.prototype.connectionType=a},_s:[],supportedConnectionTypes:function(){return Faye.map(this._s,function(a){return a[0]})}});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,_t: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._t)||(d&&d!==h._m)||(f&&f!==h._n))continue;if(h._i.removeEventListener)h._i.removeEventListener(h._t,h._C,false);else h._i.detachEvent('on'+h._t,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);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}var l=i.search.replace(/^\?/,''),n=l?l.split('&'):[],o=n.length,m={};while(o--){k=n[o].split('=');m[decodeURIComponent(k[0]||'')]=decodeURIComponent(k[1]||'')}if(typeof h==='object')Faye.extend(m,h);i.params=m;return i}});if(!this.JSON){JSON={}}(function(){function l(a){return a<10?'0'+a:a}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(a){return this.getUTCFullYear()+'-'+l(this.getUTCMonth()+1)+'-'+l(this.getUTCDate())+'T'+l(this.getUTCHours())+':'+l(this.getUTCMinutes())+':'+l(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,m,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=m,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'}m+=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?'[]':m?'[\n'+m+k.join(',\n'+m)+'\n'+i+']':'['+k.join(',')+']';m=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)+(m?': ':':')+g)}}}}else{for(f in j){if(Object.hasOwnProperty.call(j,f)){g=r(f,j);if(g){k.push(s(f)+(m?': ':':')+g)}}}}g=k.length===0?'{}':m?'{\n'+m+k.join(',\n'+m)+'\n'+i+'}':'{'+k.join(',')+'}';m=i;return g}}Faye.stringify=function(a,b,d){var f;m='';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._D)return;this._D=true;if(this._4)this._4.close()},connect:function(){if(Faye.Transport.WebSocket._K)return;if(this._D)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._4=new g(Faye.Transport.WebSocket.getSocketUrl(this.endpoint));var h=this;this._4.onopen=function(){h._1=h.CONNECTED;h._u=true;h.setDeferredStatus('succeeded',h._4);h.trigger('up')};this._4.onmessage=function(a){var b=[].concat(JSON.parse(a.data));for(var d=0,f=b.length;d<f;d++){delete h._d[b[d].id]}h.receive(b)};this._4.onclose=function(){var a=(h._1===h.CONNECTED);h.setDeferredStatus('deferred');h._1=h.UNCONNECTED;delete h._4;if(a)return h.resend();if(!h._u)return h.setDeferredStatus('failed');var b=h._7.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._K=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._L=new Faye.Transport.XHR(b,d);var f=new EventSource(d+'/'+b.getClientId()),g=this;f.onopen=function(){g._u=true;g.setDeferredStatus('succeeded');g.trigger('up')};f.onerror=function(){if(g._u){g.trigger('down')}else{g.setDeferredStatus('failed');f.close()}};f.onmessage=function(a){g.receive(JSON.parse(a.data));g.trigger('up')};this._4=f},isUsable:function(a,b){this.callback(function(){a.call(b,true)});this.errback(function(){a.call(b,false)})},request:function(a,b){this._L.request(a,b)},close:function(){this._4.close()}}),{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||{};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 l=this.headers;for(var n in l){if(!l.hasOwnProperty(n))continue;j.setRequestHeader(n,l[n])}var o=function(){j.abort()};Faye.Event.on(Faye.ENV,'beforeunload',o);var m=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){m();h();return k.trigger('down')}try{a=JSON.parse(j.responseText)}catch(e){}m();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(l);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 l=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._v+'__'};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),l=this;Faye.ENV[i]=function(a){o();l.receive(a);l.trigger('up')};var n=Faye.ENV.setTimeout(function(){o();j();l.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)}}),{_v:0,getCallbackName:function(){this._v+=1;return'__jsonp'+this._v+'__'},isUsable:function(a,b,d,f){d.call(f,true)}});Faye.Transport.register('callback-polling',Faye.Transport.JSONP);
1
+ 'use strict';var Faye={VERSION:'0.8.9',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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@)| |\/|\*|\.))*(,(((([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);
2
2
  //@ sourceMappingURL=faye-browser-min.js.map
@@ -3,6 +3,6 @@
3
3
  "file": "faye-browser-min.js",
4
4
  "sourceRoot": "",
5
5
  "sources": ["faye-browser.js"],
6
- "names": ["_advice", "_callback", "_callbacks", "_cancelled", "_cbCount", "_channels", "_client", "_clientId", "_closed", "_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", "args", "array", "banner", "bitlength", "bridge", "c", "callback", "callbackName", "callbacks", "called", "calls", "channel", "channels", "chars", "cleanUp", "client", "clone", "code", "connEndpoint", "connType", "connectionTypes", "consume", "context", "copy", "cx", "data", "date", "day", "dead", "delay", "dest", "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": "AAAA,IAAI,MAAQ,OAAO,QAAU,SAAW,QACxC,GAAI,OAAO,UAAY,WAAY,OAAO,KAAO,KAEjD,KAAK,OAAS,SAASiF,EAAM8F,EAAQ/B,GACnC,IAAK+B,EAAQ,OAAO9F,EACpB,IAAK,IAAI8B,EAAI,GAAGgE,GACd,IAAKA,EAAO,eAAehE,GAAM,SACjC,GAAI9B,EAAK,eAAe8B,IAAQiC,IAAc,MAAO,SACrD,GAAI/D,EAAK8B,KAASgE,EAAOhE,GACvB9B,EAAK8B,GAAOgE,EAAOhE,GAEvB,OAAO9B,GAGT,KAAK,OAAO,MACV,gBAEA,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,WAAa,OAAO,SAE1B,OAAQ,SAAS3B,GACfA,EAAYA,GAAa,K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AIlH,GAAgB,SAASkB,GAChCX,IACA2G,EAAK,QAAQhG,GACbgG,EAAK,SAAS,MAGhB,IAAIa,EAAQ,KAAK,IAAI,WAAW,WAC9BxH,IACAqG,IACAM,EAAK,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,EAAUgB,GAC7ChB,EAAS,KAAKgB,EAAS,SAI3B,KAAK,UAAU,UAAU,SAAS,SAAU,KAAK,UAAU;"
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,gBAEA,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,MAA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B,KAAK,IAAIlH,GAAgB,SAASiB,GAChCV,IACA2G,EAAK,QAAQjG,GACbiG,EAAK,SAAS,MAGhB,IAAIa,EAAQ,KAAK,IAAI,WAAW,WAC9BxH,IACAqG,IACAM,EAAK,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
8
  }
@@ -1,29 +1,28 @@
1
- var Faye = (typeof Faye === 'object') ? Faye : {};
2
- if (typeof window !== 'undefined') window.Faye = Faye;
3
-
4
- Faye.extend = function(dest, source, overwrite) {
5
- if (!source) return dest;
6
- for (var key in source) {
7
- if (!source.hasOwnProperty(key)) continue;
8
- if (dest.hasOwnProperty(key) && overwrite === false) continue;
9
- if (dest[key] !== source[key])
10
- dest[key] = source[key];
11
- }
12
- return dest;
13
- };
1
+ 'use strict';
2
+
3
+ var Faye = {
4
+ VERSION: '0.8.9',
14
5
 
15
- Faye.extend(Faye, {
16
- VERSION: '0.8.8',
17
-
18
6
  BAYEUX_VERSION: '1.0',
19
7
  ID_LENGTH: 160,
20
8
  JSONP_CALLBACK: 'jsonpcallback',
21
9
  CONNECTION_TYPES: ['long-polling', 'cross-origin-long-polling', 'callback-polling', 'websocket', 'eventsource', 'in-process'],
22
-
10
+
23
11
  MANDATORY_CONNECTION_TYPES: ['long-polling', 'callback-polling', 'in-process'],
24
-
25
- ENV: (function() { return this })(),
26
-
12
+
13
+ ENV: (typeof global === 'undefined') ? window : global,
14
+
15
+ extend: function(dest, source, overwrite) {
16
+ if (!source) return dest;
17
+ for (var key in source) {
18
+ if (!source.hasOwnProperty(key)) continue;
19
+ if (dest.hasOwnProperty(key) && overwrite === false) continue;
20
+ if (dest[key] !== source[key])
21
+ dest[key] = source[key];
22
+ }
23
+ return dest;
24
+ },
25
+
27
26
  random: function(bitlength) {
28
27
  bitlength = bitlength || this.ID_LENGTH;
29
28
  if (bitlength > 32) {
@@ -37,16 +36,16 @@ Faye.extend(Faye, {
37
36
  var limit = Math.pow(2, bitlength) - 1,
38
37
  maxSize = limit.toString(36).length,
39
38
  string = Math.floor(Math.random() * limit).toString(36);
40
-
39
+
41
40
  while (string.length < maxSize) string = '0' + string;
42
41
  return string;
43
42
  },
44
-
43
+
45
44
  clientIdFromMessages: function(messages) {
46
45
  var first = [].concat(messages)[0];
47
46
  return first && first.clientId;
48
47
  },
49
-
48
+
50
49
  copyObject: function(object) {
51
50
  var clone, i, key;
52
51
  if (object instanceof Array) {
@@ -62,7 +61,7 @@ Faye.extend(Faye, {
62
61
  return object;
63
62
  }
64
63
  },
65
-
64
+
66
65
  commonElement: function(lista, listb) {
67
66
  for (var i = 0, n = lista.length; i < n; i++) {
68
67
  if (this.indexOf(listb, lista[i]) !== -1)
@@ -70,20 +69,20 @@ Faye.extend(Faye, {
70
69
  }
71
70
  return null;
72
71
  },
73
-
72
+
74
73
  indexOf: function(list, needle) {
75
74
  if (list.indexOf) return list.indexOf(needle);
76
-
75
+
77
76
  for (var i = 0, n = list.length; i < n; i++) {
78
77
  if (list[i] === needle) return i;
79
78
  }
80
79
  return -1;
81
80
  },
82
-
81
+
83
82
  map: function(object, callback, context) {
84
83
  if (object.map) return object.map(callback, context);
85
84
  var result = [];
86
-
85
+
87
86
  if (object instanceof Array) {
88
87
  for (var i = 0, n = object.length; i < n; i++) {
89
88
  result.push(callback.call(context || null, object[i], i));
@@ -96,7 +95,7 @@ Faye.extend(Faye, {
96
95
  }
97
96
  return result;
98
97
  },
99
-
98
+
100
99
  filter: function(array, callback, context) {
101
100
  var result = [];
102
101
  for (var i = 0, n = array.length; i < n; i++) {
@@ -105,7 +104,7 @@ Faye.extend(Faye, {
105
104
  }
106
105
  return result;
107
106
  },
108
-
107
+
109
108
  asyncEach: function(list, iterator, callback, context) {
110
109
  var n = list.length,
111
110
  i = -1,
@@ -132,7 +131,7 @@ Faye.extend(Faye, {
132
131
  };
133
132
  resume();
134
133
  },
135
-
134
+
136
135
  // http://assanka.net/content/tech/2009/09/02/json2-js-vs-prototype/
137
136
  toJSON: function(object) {
138
137
  if (this.stringify)
@@ -141,14 +140,14 @@ Faye.extend(Faye, {
141
140
  ? this[key]
142
141
  : value;
143
142
  });
144
-
143
+
145
144
  return JSON.stringify(object);
146
145
  },
147
-
146
+
148
147
  logger: function(message) {
149
148
  if (typeof console !== 'undefined') console.log(message);
150
149
  },
151
-
150
+
152
151
  timestamp: function() {
153
152
  var date = new Date(),
154
153
  year = date.getFullYear(),
@@ -157,15 +156,18 @@ Faye.extend(Faye, {
157
156
  hour = date.getHours(),
158
157
  minute = date.getMinutes(),
159
158
  second = date.getSeconds();
160
-
159
+
161
160
  var pad = function(n) {
162
161
  return n < 10 ? '0' + n : String(n);
163
162
  };
164
-
163
+
165
164
  return pad(year) + '-' + pad(month) + '-' + pad(day) + ' ' +
166
165
  pad(hour) + ':' + pad(minute) + ':' + pad(second);
167
166
  }
168
- });
167
+ };
168
+
169
+ if (typeof window !== 'undefined')
170
+ window.Faye = Faye;
169
171
 
170
172
 
171
173
  Faye.Class = function(parent, methods) {
@@ -173,18 +175,18 @@ Faye.Class = function(parent, methods) {
173
175
  methods = parent;
174
176
  parent = Object;
175
177
  }
176
-
178
+
177
179
  var klass = function() {
178
180
  if (!this.initialize) return this;
179
181
  return this.initialize.apply(this, arguments) || this;
180
182
  };
181
-
183
+
182
184
  var bridge = function() {};
183
185
  bridge.prototype = parent.prototype;
184
-
186
+
185
187
  klass.prototype = new bridge();
186
188
  Faye.extend(klass.prototype, methods);
187
-
189
+
188
190
  return klass;
189
191
  };
190
192
 
@@ -193,18 +195,18 @@ Faye.Namespace = Faye.Class({
193
195
  initialize: function() {
194
196
  this._used = {};
195
197
  },
196
-
198
+
197
199
  exists: function(id) {
198
200
  return this._used.hasOwnProperty(id);
199
201
  },
200
-
202
+
201
203
  generate: function() {
202
204
  var name = Faye.random();
203
205
  while (this._used.hasOwnProperty(name))
204
206
  name = Faye.random();
205
207
  return this._used[name] = name;
206
208
  },
207
-
209
+
208
210
  release: function(id) {
209
211
  delete this._used[id];
210
212
  }
@@ -217,7 +219,7 @@ Faye.Error = Faye.Class({
217
219
  this.params = Array.prototype.slice.call(params);
218
220
  this.message = message;
219
221
  },
220
-
222
+
221
223
  toString: function() {
222
224
  return this.code + ':' +
223
225
  this.params.join(',') + ':' +
@@ -278,14 +280,14 @@ Faye.Error.serverError = function() {
278
280
  Faye.Deferrable = {
279
281
  callback: function(callback, context) {
280
282
  if (!callback) return;
281
-
283
+
282
284
  if (this._deferredStatus === 'succeeded')
283
285
  return callback.apply(context, this._deferredArgs);
284
-
286
+
285
287
  this._callbacks = this._callbacks || [];
286
288
  this._callbacks.push([callback, context]);
287
289
  },
288
-
290
+
289
291
  timeout: function(seconds, message) {
290
292
  var _this = this;
291
293
  var timer = Faye.ENV.setTimeout(function() {
@@ -293,7 +295,7 @@ Faye.Deferrable = {
293
295
  }, seconds * 1000);
294
296
  this._timer = timer;
295
297
  },
296
-
298
+
297
299
  errback: function(callback, context) {
298
300
  if (!callback) return;
299
301
 
@@ -311,17 +313,17 @@ Faye.Deferrable = {
311
313
  var args = Array.prototype.slice.call(arguments),
312
314
  status = args.shift(),
313
315
  callbacks;
314
-
316
+
315
317
  this._deferredStatus = status;
316
318
  this._deferredArgs = args;
317
-
319
+
318
320
  if (status === 'succeeded')
319
321
  callbacks = this._callbacks;
320
322
  else if (status === 'failed')
321
323
  callbacks = this._errbacks;
322
-
324
+
323
325
  if (!callbacks) return;
324
-
326
+
325
327
  var callback;
326
328
  while (callback = callbacks.shift())
327
329
  callback[0].apply(callback[1], this._deferredArgs);
@@ -334,39 +336,39 @@ Faye.Publisher = {
334
336
  if (!this._subscribers || !this._subscribers[eventType]) return 0;
335
337
  return this._subscribers[eventType].length;
336
338
  },
337
-
339
+
338
340
  bind: function(eventType, listener, context) {
339
341
  this._subscribers = this._subscribers || {};
340
342
  var list = this._subscribers[eventType] = this._subscribers[eventType] || [];
341
343
  list.push([listener, context]);
342
344
  },
343
-
345
+
344
346
  unbind: function(eventType, listener, context) {
345
347
  if (!this._subscribers || !this._subscribers[eventType]) return;
346
-
348
+
347
349
  if (!listener) {
348
350
  delete this._subscribers[eventType];
349
351
  return;
350
352
  }
351
353
  var list = this._subscribers[eventType],
352
354
  i = list.length;
353
-
355
+
354
356
  while (i--) {
355
357
  if (listener !== list[i][0]) continue;
356
358
  if (context && list[i][1] !== context) continue;
357
359
  list.splice(i,1);
358
360
  }
359
361
  },
360
-
362
+
361
363
  trigger: function() {
362
364
  var args = Array.prototype.slice.call(arguments),
363
365
  eventType = args.shift();
364
-
366
+
365
367
  if (!this._subscribers || !this._subscribers[eventType]) return;
366
-
368
+
367
369
  var listeners = this._subscribers[eventType].slice(),
368
370
  listener;
369
-
371
+
370
372
  for (var i = 0, n = listeners.length; i < n; i++) {
371
373
  listener = listeners[i];
372
374
  listener[0].apply(listener[1], args);
@@ -385,7 +387,7 @@ Faye.Timeouts = {
385
387
  callback.call(context);
386
388
  }, 1000 * delay);
387
389
  },
388
-
390
+
389
391
  removeTimeout: function(name) {
390
392
  this._timeouts = this._timeouts || {};
391
393
  var timeout = this._timeouts[name];
@@ -403,19 +405,19 @@ Faye.Logging = {
403
405
  info: 1,
404
406
  debug: 0
405
407
  },
406
-
408
+
407
409
  logLevel: 'error',
408
-
410
+
409
411
  log: function(messageArgs, level) {
410
412
  if (!Faye.logger) return;
411
-
413
+
412
414
  var levels = Faye.Logging.LOG_LEVELS;
413
415
  if (levels[Faye.Logging.logLevel] > levels[level]) return;
414
-
416
+
415
417
  var messageArgs = Array.prototype.slice.apply(messageArgs),
416
418
  banner = ' [' + level.toUpperCase() + '] [Faye',
417
419
  klass = this.className,
418
-
420
+
419
421
  message = messageArgs.shift().replace(/\?/g, function() {
420
422
  try {
421
423
  return Faye.toJSON(messageArgs.shift());
@@ -423,7 +425,7 @@ Faye.Logging = {
423
425
  return '[Object]';
424
426
  }
425
427
  });
426
-
428
+
427
429
  for (var key in Faye) {
428
430
  if (klass) continue;
429
431
  if (typeof Faye[key] !== 'function') continue;
@@ -431,7 +433,7 @@ Faye.Logging = {
431
433
  }
432
434
  if (klass) banner += '.' + klass;
433
435
  banner += '] ';
434
-
436
+
435
437
  Faye.logger(Faye.timestamp() + banner + message);
436
438
  }
437
439
  };
@@ -478,7 +480,7 @@ Faye.Extensible = {
478
480
  this._extensions.push(extension);
479
481
  if (extension.added) extension.added(this);
480
482
  },
481
-
483
+
482
484
  removeExtension: function(extension) {
483
485
  if (!this._extensions) return;
484
486
  var i = this._extensions.length;
@@ -488,19 +490,19 @@ Faye.Extensible = {
488
490
  if (extension.removed) extension.removed(this);
489
491
  }
490
492
  },
491
-
493
+
492
494
  pipeThroughExtensions: function(stage, message, callback, context) {
493
495
  this.debug('Passing through ? extensions: ?', stage, message);
494
496
 
495
497
  if (!this._extensions) return callback.call(context, message);
496
498
  var extensions = this._extensions.slice();
497
-
499
+
498
500
  var pipe = function(message) {
499
501
  if (!message) return callback.call(context, message);
500
-
502
+
501
503
  var extension = extensions.shift();
502
504
  if (!extension) return callback.call(context, message);
503
-
505
+
504
506
  if (extension[stage]) extension[stage](message, pipe);
505
507
  else pipe(message);
506
508
  };
@@ -514,11 +516,11 @@ Faye.Channel = Faye.Class({
514
516
  initialize: function(name) {
515
517
  this.id = this.name = name;
516
518
  },
517
-
519
+
518
520
  push: function(message) {
519
521
  this.trigger('message', message);
520
522
  },
521
-
523
+
522
524
  isUnused: function() {
523
525
  return this.countListeners('message') === 0;
524
526
  }
@@ -532,75 +534,75 @@ Faye.extend(Faye.Channel, {
532
534
  SUBSCRIBE: '/meta/subscribe',
533
535
  UNSUBSCRIBE: '/meta/unsubscribe',
534
536
  DISCONNECT: '/meta/disconnect',
535
-
537
+
536
538
  META: 'meta',
537
539
  SERVICE: 'service',
538
-
540
+
539
541
  expand: function(name) {
540
542
  var segments = this.parse(name),
541
543
  channels = ['/**', name];
542
-
544
+
543
545
  var copy = segments.slice();
544
546
  copy[copy.length - 1] = '*';
545
547
  channels.push(this.unparse(copy));
546
-
548
+
547
549
  for (var i = 1, n = segments.length; i < n; i++) {
548
550
  copy = segments.slice(0, i);
549
551
  copy.push('**');
550
552
  channels.push(this.unparse(copy));
551
553
  }
552
-
554
+
553
555
  return channels;
554
556
  },
555
-
557
+
556
558
  isValid: function(name) {
557
559
  return Faye.Grammar.CHANNEL_NAME.test(name) ||
558
560
  Faye.Grammar.CHANNEL_PATTERN.test(name);
559
561
  },
560
-
562
+
561
563
  parse: function(name) {
562
564
  if (!this.isValid(name)) return null;
563
565
  return name.split('/').slice(1);
564
566
  },
565
-
567
+
566
568
  unparse: function(segments) {
567
569
  return '/' + segments.join('/');
568
570
  },
569
-
571
+
570
572
  isMeta: function(name) {
571
573
  var segments = this.parse(name);
572
574
  return segments ? (segments[0] === this.META) : null;
573
575
  },
574
-
576
+
575
577
  isService: function(name) {
576
578
  var segments = this.parse(name);
577
579
  return segments ? (segments[0] === this.SERVICE) : null;
578
580
  },
579
-
581
+
580
582
  isSubscribable: function(name) {
581
583
  if (!this.isValid(name)) return null;
582
584
  return !this.isMeta(name) && !this.isService(name);
583
585
  },
584
-
586
+
585
587
  Set: Faye.Class({
586
588
  initialize: function() {
587
589
  this._channels = {};
588
590
  },
589
-
591
+
590
592
  getKeys: function() {
591
593
  var keys = [];
592
594
  for (var key in this._channels) keys.push(key);
593
595
  return keys;
594
596
  },
595
-
597
+
596
598
  remove: function(name) {
597
599
  delete this._channels[name];
598
600
  },
599
-
601
+
600
602
  hasSubscription: function(name) {
601
603
  return this._channels.hasOwnProperty(name);
602
604
  },
603
-
605
+
604
606
  subscribe: function(names, callback, context) {
605
607
  if (!callback) return;
606
608
  var name;
@@ -610,12 +612,12 @@ Faye.extend(Faye.Channel, {
610
612
  channel.bind('message', callback, context);
611
613
  }
612
614
  },
613
-
615
+
614
616
  unsubscribe: function(name, callback, context) {
615
617
  var channel = this._channels[name];
616
618
  if (!channel) return false;
617
619
  channel.unbind('message', callback, context);
618
-
620
+
619
621
  if (channel.isUnused()) {
620
622
  this.remove(name);
621
623
  return true;
@@ -623,10 +625,10 @@ Faye.extend(Faye.Channel, {
623
625
  return false;
624
626
  }
625
627
  },
626
-
628
+
627
629
  distributeMessage: function(message) {
628
630
  var channels = Faye.Channel.expand(message.channel);
629
-
631
+
630
632
  for (var i = 0, n = channels.length; i < n; i++) {
631
633
  var channel = this._channels[channels[i]];
632
634
  if (channel) channel.trigger('message', message.data);
@@ -647,13 +649,13 @@ Faye.Subscription = Faye.Class({
647
649
  this._context = context;
648
650
  this._cancelled = false;
649
651
  },
650
-
652
+
651
653
  cancel: function() {
652
654
  if (this._cancelled) return;
653
655
  this._client.unsubscribe(this._channels, this._callback, this._context);
654
656
  this._cancelled = true;
655
657
  },
656
-
658
+
657
659
  unsubscribe: function() {
658
660
  this.cancel();
659
661
  }
@@ -667,20 +669,20 @@ Faye.Client = Faye.Class({
667
669
  CONNECTING: 2,
668
670
  CONNECTED: 3,
669
671
  DISCONNECTED: 4,
670
-
672
+
671
673
  HANDSHAKE: 'handshake',
672
674
  RETRY: 'retry',
673
675
  NONE: 'none',
674
-
676
+
675
677
  CONNECTION_TIMEOUT: 60.0,
676
678
  DEFAULT_RETRY: 5.0,
677
-
679
+
678
680
  DEFAULT_ENDPOINT: '/bayeux',
679
681
  INTERVAL: 0.0,
680
-
682
+
681
683
  initialize: function(endpoint, options) {
682
684
  this.info('New client created for ?', endpoint);
683
-
685
+
684
686
  this._options = options || {};
685
687
  this.endpoint = endpoint || this.DEFAULT_ENDPOINT;
686
688
  this.endpoints = this._options.endpoints || {};
@@ -689,36 +691,34 @@ Faye.Client = Faye.Class({
689
691
  this._headers = {};
690
692
  this._disabled = [];
691
693
  this.retry = this._options.retry || this.DEFAULT_RETRY;
692
-
693
- this._selectTransport(Faye.MANDATORY_CONNECTION_TYPES);
694
-
694
+
695
695
  this._state = this.UNCONNECTED;
696
696
  this._channels = new Faye.Channel.Set();
697
697
  this._messageId = 0;
698
-
698
+
699
699
  this._responseCallbacks = {};
700
-
700
+
701
701
  this._advice = {
702
702
  reconnect: this.RETRY,
703
703
  interval: 1000 * (this._options.interval || this.INTERVAL),
704
704
  timeout: 1000 * (this._options.timeout || this.CONNECTION_TIMEOUT)
705
705
  };
706
-
706
+
707
707
  if (Faye.Event)
708
708
  Faye.Event.on(Faye.ENV, 'beforeunload', function() {
709
709
  if (Faye.indexOf(this._disabled, 'autodisconnect') < 0)
710
710
  this.disconnect();
711
711
  }, this);
712
712
  },
713
-
713
+
714
714
  disable: function(feature) {
715
715
  this._disabled.push(feature);
716
716
  },
717
-
717
+
718
718
  setHeader: function(name, value) {
719
719
  this._headers[name] = value;
720
720
  },
721
-
721
+
722
722
  getClientId: function() {
723
723
  return this._clientId;
724
724
  },
@@ -739,7 +739,7 @@ Faye.Client = Faye.Class({
739
739
  // MAY include: * minimumVersion
740
740
  // * ext
741
741
  // * id
742
- //
742
+ //
743
743
  // Success Response Failed Response
744
744
  // MUST include: * channel MUST include: * channel
745
745
  // * version * successful
@@ -754,33 +754,31 @@ Faye.Client = Faye.Class({
754
754
  handshake: function(callback, context) {
755
755
  if (this._advice.reconnect === this.NONE) return;
756
756
  if (this._state !== this.UNCONNECTED) return;
757
-
757
+
758
758
  this._state = this.CONNECTING;
759
759
  var self = this;
760
-
760
+
761
761
  this.info('Initiating handshake with ?', this.endpoint);
762
-
762
+ this._selectTransport(Faye.MANDATORY_CONNECTION_TYPES);
763
+
763
764
  this._send({
764
765
  channel: Faye.Channel.HANDSHAKE,
765
766
  version: Faye.BAYEUX_VERSION,
766
767
  supportedConnectionTypes: [this._transport.connectionType]
767
-
768
+
768
769
  }, function(response) {
769
-
770
+
770
771
  if (response.successful) {
771
772
  this._state = this.CONNECTED;
772
773
  this._clientId = response.clientId;
773
-
774
- var connectionTypes = Faye.filter(response.supportedConnectionTypes, function(connType) {
775
- return Faye.indexOf(this._disabled, connType) < 0;
776
- }, this);
777
- this._selectTransport(connectionTypes);
778
-
774
+
775
+ this._selectTransport(response.supportedConnectionTypes);
776
+
779
777
  this.info('Handshake successful: ?', this._clientId);
780
-
778
+
781
779
  this.subscribe(this._channels.getKeys(), true);
782
780
  if (callback) callback.call(context);
783
-
781
+
784
782
  } else {
785
783
  this.info('Handshake unsuccessful');
786
784
  Faye.ENV.setTimeout(function() { self.handshake(callback, context) }, this._advice.interval);
@@ -788,7 +786,7 @@ Faye.Client = Faye.Class({
788
786
  }
789
787
  }, this);
790
788
  },
791
-
789
+
792
790
  // Request Response
793
791
  // MUST include: * channel MUST include: * channel
794
792
  // * clientId * successful
@@ -801,30 +799,30 @@ Faye.Client = Faye.Class({
801
799
  connect: function(callback, context) {
802
800
  if (this._advice.reconnect === this.NONE) return;
803
801
  if (this._state === this.DISCONNECTED) return;
804
-
802
+
805
803
  if (this._state === this.UNCONNECTED)
806
804
  return this.handshake(function() { this.connect(callback, context) }, this);
807
-
805
+
808
806
  this.callback(callback, context);
809
807
  if (this._state !== this.CONNECTED) return;
810
-
808
+
811
809
  this.info('Calling deferred actions for ?', this._clientId);
812
810
  this.setDeferredStatus('succeeded');
813
811
  this.setDeferredStatus('deferred');
814
-
812
+
815
813
  if (this._connectRequest) return;
816
814
  this._connectRequest = true;
817
-
815
+
818
816
  this.info('Initiating connection for ?', this._clientId);
819
-
817
+
820
818
  this._send({
821
819
  channel: Faye.Channel.CONNECT,
822
820
  clientId: this._clientId,
823
821
  connectionType: this._transport.connectionType
824
-
822
+
825
823
  }, this._cycleConnection, this);
826
824
  },
827
-
825
+
828
826
  // Request Response
829
827
  // MUST include: * channel MUST include: * channel
830
828
  // * clientId * successful
@@ -835,21 +833,21 @@ Faye.Client = Faye.Class({
835
833
  disconnect: function() {
836
834
  if (this._state !== this.CONNECTED) return;
837
835
  this._state = this.DISCONNECTED;
838
-
836
+
839
837
  this.info('Disconnecting ?', this._clientId);
840
-
838
+
841
839
  this._send({
842
840
  channel: Faye.Channel.DISCONNECT,
843
841
  clientId: this._clientId
844
-
842
+
845
843
  }, function(response) {
846
844
  if (response.successful) this._transport.close();
847
845
  }, this);
848
-
846
+
849
847
  this.info('Clearing channel listeners for ?', this._clientId);
850
848
  this._channels = new Faye.Channel.Set();
851
849
  },
852
-
850
+
853
851
  // Request Response
854
852
  // MUST include: * channel MUST include: * channel
855
853
  // * clientId * successful
@@ -865,41 +863,41 @@ Faye.Client = Faye.Class({
865
863
  return Faye.map(channel, function(c) {
866
864
  return this.subscribe(c, callback, context);
867
865
  }, this);
868
-
866
+
869
867
  var subscription = new Faye.Subscription(this, channel, callback, context),
870
868
  force = (callback === true),
871
869
  hasSubscribe = this._channels.hasSubscription(channel);
872
-
870
+
873
871
  if (hasSubscribe && !force) {
874
872
  this._channels.subscribe([channel], callback, context);
875
873
  subscription.setDeferredStatus('succeeded');
876
874
  return subscription;
877
875
  }
878
-
876
+
879
877
  this.connect(function() {
880
878
  this.info('Client ? attempting to subscribe to ?', this._clientId, channel);
881
879
  if (!force) this._channels.subscribe([channel], callback, context);
882
-
880
+
883
881
  this._send({
884
882
  channel: Faye.Channel.SUBSCRIBE,
885
883
  clientId: this._clientId,
886
884
  subscription: channel
887
-
885
+
888
886
  }, function(response) {
889
887
  if (!response.successful) {
890
888
  subscription.setDeferredStatus('failed', Faye.Error.parse(response.error));
891
889
  return this._channels.unsubscribe(channel, callback, context);
892
890
  }
893
-
891
+
894
892
  var channels = [].concat(response.subscription);
895
893
  this.info('Subscription acknowledged for ? to ?', this._clientId, channels);
896
894
  subscription.setDeferredStatus('succeeded');
897
895
  }, this);
898
896
  }, this);
899
-
897
+
900
898
  return subscription;
901
899
  },
902
-
900
+
903
901
  // Request Response
904
902
  // MUST include: * channel MUST include: * channel
905
903
  // * clientId * successful
@@ -915,27 +913,27 @@ Faye.Client = Faye.Class({
915
913
  return Faye.map(channel, function(c) {
916
914
  return this.unsubscribe(c, callback, context);
917
915
  }, this);
918
-
916
+
919
917
  var dead = this._channels.unsubscribe(channel, callback, context);
920
918
  if (!dead) return;
921
-
919
+
922
920
  this.connect(function() {
923
921
  this.info('Client ? attempting to unsubscribe from ?', this._clientId, channel);
924
-
922
+
925
923
  this._send({
926
924
  channel: Faye.Channel.UNSUBSCRIBE,
927
925
  clientId: this._clientId,
928
926
  subscription: channel
929
-
927
+
930
928
  }, function(response) {
931
929
  if (!response.successful) return;
932
-
930
+
933
931
  var channels = [].concat(response.subscription);
934
932
  this.info('Unsubscription acknowledged for ? from ?', this._clientId, channels);
935
933
  }, this);
936
934
  }, this);
937
935
  },
938
-
936
+
939
937
  // Request Response
940
938
  // MUST include: * channel MUST include: * channel
941
939
  // * data * successful
@@ -944,10 +942,10 @@ Faye.Client = Faye.Class({
944
942
  // * ext * ext
945
943
  publish: function(channel, data) {
946
944
  var publication = new Faye.Publication();
947
-
945
+
948
946
  this.connect(function() {
949
947
  this.info('Client ? queueing published message to ?: ?', this._clientId, channel, data);
950
-
948
+
951
949
  this._send({
952
950
  channel: channel,
953
951
  data: data,
@@ -959,41 +957,44 @@ Faye.Client = Faye.Class({
959
957
  publication.setDeferredStatus('failed', Faye.Error.parse(response.error));
960
958
  }, this);
961
959
  }, this);
962
-
960
+
963
961
  return publication;
964
962
  },
965
-
963
+
966
964
  receiveMessage: function(message) {
967
965
  this.pipeThroughExtensions('incoming', message, function(message) {
968
966
  if (!message) return;
969
-
967
+
970
968
  if (message.advice) this._handleAdvice(message.advice);
971
969
  this._deliverMessage(message);
972
-
970
+
973
971
  if (message.successful === undefined) return;
974
-
972
+
975
973
  var callback = this._responseCallbacks[message.id];
976
974
  if (!callback) return;
977
-
975
+
978
976
  delete this._responseCallbacks[message.id];
979
977
  callback[0].call(callback[1], message);
980
978
  }, this);
981
979
  },
982
-
980
+
983
981
  _selectTransport: function(transportTypes) {
984
- Faye.Transport.get(this, transportTypes, function(transport) {
982
+ Faye.Transport.get(this, transportTypes, this._disabled, function(transport) {
985
983
  this.debug('Selected ? transport for ?', transport.connectionType, transport.endpoint);
986
-
984
+
985
+ if (transport === this._transport) return;
986
+ if (this._transport) this._transport.close();
987
+
987
988
  this._transport = transport;
988
989
  this._transport.cookies = this._cookies;
989
990
  this._transport.headers = this._headers;
990
-
991
+
991
992
  transport.bind('down', function() {
992
993
  if (this._transportUp !== undefined && !this._transportUp) return;
993
994
  this._transportUp = false;
994
995
  this.trigger('transport:down');
995
996
  }, this);
996
-
997
+
997
998
  transport.bind('up', function() {
998
999
  if (this._transportUp !== undefined && this._transportUp) return;
999
1000
  this._transportUp = true;
@@ -1001,7 +1002,7 @@ Faye.Client = Faye.Class({
1001
1002
  }, this);
1002
1003
  }, this);
1003
1004
  },
1004
-
1005
+
1005
1006
  _send: function(message, callback, context) {
1006
1007
  message.id = this._generateMessageId();
1007
1008
  if (callback) this._responseCallbacks[message.id] = [callback, context];
@@ -1011,7 +1012,7 @@ Faye.Client = Faye.Class({
1011
1012
  this._transport.send(message, this._advice.timeout / 1000);
1012
1013
  }, this);
1013
1014
  },
1014
-
1015
+
1015
1016
  _generateMessageId: function() {
1016
1017
  this._messageId += 1;
1017
1018
  if (this._messageId >= Math.pow(2,32)) this._messageId = 0;
@@ -1020,26 +1021,26 @@ Faye.Client = Faye.Class({
1020
1021
 
1021
1022
  _handleAdvice: function(advice) {
1022
1023
  Faye.extend(this._advice, advice);
1023
-
1024
+
1024
1025
  if (this._advice.reconnect === this.HANDSHAKE && this._state !== this.DISCONNECTED) {
1025
1026
  this._state = this.UNCONNECTED;
1026
1027
  this._clientId = null;
1027
1028
  this._cycleConnection();
1028
1029
  }
1029
1030
  },
1030
-
1031
+
1031
1032
  _deliverMessage: function(message) {
1032
1033
  if (!message.channel || message.data === undefined) return;
1033
1034
  this.info('Client ? calling listeners for ? with ?', this._clientId, message.channel, message.data);
1034
1035
  this._channels.distributeMessage(message);
1035
1036
  },
1036
-
1037
+
1037
1038
  _teardownConnection: function() {
1038
1039
  if (!this._connectRequest) return;
1039
1040
  this._connectRequest = null;
1040
1041
  this.info('Closed connection for ?', this._clientId);
1041
1042
  },
1042
-
1043
+
1043
1044
  _cycleConnection: function() {
1044
1045
  this._teardownConnection();
1045
1046
  var self = this;
@@ -1062,9 +1063,9 @@ Faye.Transport = Faye.extend(Faye.Class({
1062
1063
  this.endpoint = endpoint;
1063
1064
  this._outbox = [];
1064
1065
  },
1065
-
1066
+
1066
1067
  close: function() {},
1067
-
1068
+
1068
1069
  send: function(message, timeout) {
1069
1070
  this.debug('Client ? sending message to ?: ?',
1070
1071
  this._client._clientId, this.endpoint, message);
@@ -1093,48 +1094,50 @@ Faye.Transport = Faye.extend(Faye.Class({
1093
1094
  this._connectMessage.advice = {timeout: 0};
1094
1095
 
1095
1096
  this.request(this._outbox, this._timeout);
1096
-
1097
+
1097
1098
  this._connectMessage = null;
1098
1099
  this._outbox = [];
1099
1100
  },
1100
-
1101
+
1101
1102
  receive: function(responses) {
1102
1103
  this.debug('Client ? received from ?: ?',
1103
1104
  this._client._clientId, this.endpoint, responses);
1104
-
1105
+
1105
1106
  for (var i = 0, n = responses.length; i < n; i++) {
1106
1107
  this._client.receiveMessage(responses[i]);
1107
1108
  }
1108
1109
  },
1109
-
1110
+
1110
1111
  retry: function(message, timeout) {
1111
1112
  var called = false,
1112
1113
  retry = this._client.retry * 1000,
1113
1114
  self = this;
1114
-
1115
+
1115
1116
  return function() {
1116
1117
  if (called) return;
1117
1118
  called = true;
1118
1119
  Faye.ENV.setTimeout(function() { self.request(message, timeout) }, retry);
1119
1120
  };
1120
1121
  }
1121
-
1122
+
1122
1123
  }), {
1123
1124
  MAX_URL_LENGTH: 2048,
1124
-
1125
- get: function(client, connectionTypes, callback, context) {
1125
+
1126
+ get: function(client, allowed, disabled, callback, context) {
1126
1127
  var endpoint = client.endpoint;
1127
- if (connectionTypes === undefined) connectionTypes = this.supportedConnectionTypes();
1128
-
1128
+
1129
1129
  Faye.asyncEach(this._transports, function(pair, resume) {
1130
1130
  var connType = pair[0], klass = pair[1],
1131
1131
  connEndpoint = client.endpoints[connType] || endpoint;
1132
-
1133
- if (Faye.indexOf(connectionTypes, connType) < 0) {
1132
+
1133
+ if (Faye.indexOf(disabled, connType) >= 0)
1134
+ return resume();
1135
+
1136
+ if (Faye.indexOf(allowed, connType) < 0) {
1134
1137
  klass.isUsable(client, connEndpoint, function() {});
1135
1138
  return resume();
1136
1139
  }
1137
-
1140
+
1138
1141
  klass.isUsable(client, connEndpoint, function(isUsable) {
1139
1142
  if (!isUsable) return resume();
1140
1143
  var transport = klass.hasOwnProperty('create') ? klass.create(client, connEndpoint) : new klass(client, connEndpoint);
@@ -1144,17 +1147,13 @@ Faye.Transport = Faye.extend(Faye.Class({
1144
1147
  throw new Error('Could not find a usable connection type for ' + endpoint);
1145
1148
  });
1146
1149
  },
1147
-
1150
+
1148
1151
  register: function(type, klass) {
1149
1152
  this._transports.push([type, klass]);
1150
1153
  klass.prototype.connectionType = type;
1151
1154
  },
1152
-
1153
- _transports: [],
1154
-
1155
- supportedConnectionTypes: function() {
1156
- return Faye.map(this._transports, function(pair) { return pair[0] });
1157
- }
1155
+
1156
+ _transports: []
1158
1157
  });
1159
1158
 
1160
1159
  Faye.extend(Faye.Transport.prototype, Faye.Logging);
@@ -1164,15 +1163,15 @@ Faye.extend(Faye.Transport.prototype, Faye.Timeouts);
1164
1163
 
1165
1164
  Faye.Event = {
1166
1165
  _registry: [],
1167
-
1166
+
1168
1167
  on: function(element, eventName, callback, context) {
1169
1168
  var wrapped = function() { callback.call(context) };
1170
-
1169
+
1171
1170
  if (element.addEventListener)
1172
1171
  element.addEventListener(eventName, wrapped, false);
1173
1172
  else
1174
1173
  element.attachEvent('on' + eventName, wrapped);
1175
-
1174
+
1176
1175
  this._registry.push({
1177
1176
  _element: element,
1178
1177
  _type: eventName,
@@ -1181,23 +1180,23 @@ Faye.Event = {
1181
1180
  _handler: wrapped
1182
1181
  });
1183
1182
  },
1184
-
1183
+
1185
1184
  detach: function(element, eventName, callback, context) {
1186
1185
  var i = this._registry.length, register;
1187
1186
  while (i--) {
1188
1187
  register = this._registry[i];
1189
-
1188
+
1190
1189
  if ((element && element !== register._element) ||
1191
1190
  (eventName && eventName !== register._type) ||
1192
1191
  (callback && callback !== register._callback) ||
1193
1192
  (context && context !== register._context))
1194
1193
  continue;
1195
-
1194
+
1196
1195
  if (register._element.removeEventListener)
1197
1196
  register._element.removeEventListener(register._type, register._handler, false);
1198
1197
  else
1199
1198
  register._element.detachEvent('on' + register._type, register._handler);
1200
-
1199
+
1201
1200
  this._registry.splice(i,1);
1202
1201
  register = null;
1203
1202
  }
@@ -1216,17 +1215,17 @@ Faye.URI = Faye.extend(Faye.Class({
1216
1215
  }
1217
1216
  return pairs.join('&');
1218
1217
  },
1219
-
1218
+
1220
1219
  isSameOrigin: function() {
1221
- var host = Faye.URI.parse(Faye.ENV.location.href);
1222
-
1220
+ var host = Faye.URI.parse(Faye.ENV.location.href, false);
1221
+
1223
1222
  var external = (host.hostname !== this.hostname) ||
1224
1223
  (host.port !== this.port) ||
1225
1224
  (host.protocol !== this.protocol);
1226
-
1225
+
1227
1226
  return !external;
1228
1227
  },
1229
-
1228
+
1230
1229
  toURL: function() {
1231
1230
  var query = this.queryString();
1232
1231
  return this.protocol + '//' + this.hostname + (this.port ? ':' + this.port : '') +
@@ -1236,7 +1235,7 @@ Faye.URI = Faye.extend(Faye.Class({
1236
1235
  parse: function(url, params) {
1237
1236
  if (typeof url !== 'string') return url;
1238
1237
  var uri = new this(), parts;
1239
-
1238
+
1240
1239
  var consume = function(name, pattern, infer) {
1241
1240
  url = url.replace(pattern, function(match) {
1242
1241
  uri[name] = match;
@@ -1245,15 +1244,15 @@ Faye.URI = Faye.extend(Faye.Class({
1245
1244
  if (uri[name] === undefined)
1246
1245
  uri[name] = infer ? Faye.ENV.location[name] : '';
1247
1246
  };
1248
-
1247
+
1249
1248
  consume('protocol', /^https?\:/, true);
1250
1249
  consume('host', /^\/\/[^\/]+/, true);
1251
-
1250
+
1252
1251
  if (!/^\//.test(url)) url = Faye.ENV.location.pathname.replace(/[^\/]*$/, '') + url;
1253
1252
  consume('pathname', /^\/[^\?#]*/);
1254
1253
  consume('search', /^\?[^#]*/);
1255
1254
  consume('hash', /^#.*/);
1256
-
1255
+
1257
1256
  if (/^\/\//.test(uri.host)) {
1258
1257
  uri.host = uri.host.substr(2);
1259
1258
  parts = uri.host.split(':');
@@ -1263,20 +1262,24 @@ Faye.URI = Faye.extend(Faye.Class({
1263
1262
  uri.hostname = Faye.ENV.location.hostname;
1264
1263
  uri.port = Faye.ENV.location.port;
1265
1264
  }
1266
-
1267
- var query = uri.search.replace(/^\?/, ''),
1268
- pairs = query ? query.split('&') : [],
1269
- n = pairs.length,
1270
- data = {};
1271
-
1272
- while (n--) {
1273
- parts = pairs[n].split('=');
1274
- data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');
1265
+
1266
+ if (params === false) {
1267
+ uri.params = {};
1268
+ } else {
1269
+ var query = uri.search.replace(/^\?/, ''),
1270
+ pairs = query ? query.split('&') : [],
1271
+ n = pairs.length,
1272
+ data = {};
1273
+
1274
+ while (n--) {
1275
+ parts = pairs[n].split('=');
1276
+ data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');
1277
+ }
1278
+ if (typeof params === 'object') Faye.extend(data, params);
1279
+
1280
+ uri.params = data;
1275
1281
  }
1276
- if (typeof params === 'object') Faye.extend(data, params);
1277
-
1278
- uri.params = data;
1279
-
1282
+
1280
1283
  return uri;
1281
1284
  }
1282
1285
  });
@@ -1773,75 +1776,81 @@ Faye.Transport.WebSocket = Faye.extend(Faye.Class(Faye.Transport, {
1773
1776
  CONNECTED: 3,
1774
1777
 
1775
1778
  batching: false,
1776
-
1779
+
1777
1780
  isUsable: function(callback, context) {
1778
1781
  this.callback(function() { callback.call(context, true) });
1779
1782
  this.errback(function() { callback.call(context, false) });
1780
1783
  this.connect();
1781
1784
  },
1782
-
1785
+
1783
1786
  request: function(messages, timeout) {
1784
1787
  if (messages.length === 0) return;
1785
1788
  this._messages = this._messages || {};
1786
-
1789
+
1787
1790
  for (var i = 0, n = messages.length; i < n; i++) {
1788
1791
  this._messages[messages[i].id] = messages[i];
1789
1792
  }
1790
1793
  this.callback(function(socket) { socket.send(Faye.toJSON(messages)) });
1791
1794
  this.connect();
1792
1795
  },
1793
-
1796
+
1794
1797
  close: function() {
1795
- if (this._closed) return;
1796
- this._closed = true;
1797
- if (this._socket) this._socket.close();
1798
+ if (!this._socket) return;
1799
+ this._socket.onclose = this._socket.onerror = null;
1800
+ this._socket.close();
1801
+ delete this._socket;
1802
+ this.setDeferredStatus('deferred');
1803
+ this._state = this.UNCONNECTED;
1798
1804
  },
1799
-
1805
+
1800
1806
  connect: function() {
1801
1807
  if (Faye.Transport.WebSocket._unloaded) return;
1802
- if (this._closed) return;
1803
-
1808
+
1804
1809
  this._state = this._state || this.UNCONNECTED;
1805
1810
  if (this._state !== this.UNCONNECTED) return;
1806
-
1811
+
1807
1812
  this._state = this.CONNECTING;
1808
-
1813
+
1809
1814
  var ws = Faye.Transport.WebSocket.getClass();
1810
1815
  if (!ws) return this.setDeferredStatus('failed');
1811
-
1816
+
1812
1817
  this._socket = new ws(Faye.Transport.WebSocket.getSocketUrl(this.endpoint));
1813
1818
  var self = this;
1814
-
1819
+
1815
1820
  this._socket.onopen = function() {
1816
1821
  self._state = self.CONNECTED;
1817
1822
  self._everConnected = true;
1818
1823
  self.setDeferredStatus('succeeded', self._socket);
1819
1824
  self.trigger('up');
1820
1825
  };
1821
-
1826
+
1822
1827
  this._socket.onmessage = function(event) {
1823
- var messages = [].concat(JSON.parse(event.data));
1828
+ var messages = JSON.parse(event.data);
1829
+ if (!messages) return;
1830
+ messages = [].concat(messages);
1831
+
1824
1832
  for (var i = 0, n = messages.length; i < n; i++) {
1825
1833
  delete self._messages[messages[i].id];
1826
1834
  }
1827
1835
  self.receive(messages);
1828
1836
  };
1829
-
1830
- this._socket.onclose = function() {
1837
+
1838
+ this._socket.onclose = this._socket.onerror = function() {
1831
1839
  var wasConnected = (self._state === self.CONNECTED);
1832
1840
  self.setDeferredStatus('deferred');
1833
1841
  self._state = self.UNCONNECTED;
1834
- delete self._socket;
1835
-
1842
+
1843
+ self.close();
1844
+
1836
1845
  if (wasConnected) return self.resend();
1837
1846
  if (!self._everConnected) return self.setDeferredStatus('failed');
1838
-
1847
+
1839
1848
  var retry = self._client.retry * 1000;
1840
1849
  Faye.ENV.setTimeout(function() { self.connect() }, retry);
1841
1850
  self.trigger('down');
1842
1851
  };
1843
1852
  },
1844
-
1853
+
1845
1854
  resend: function() {
1846
1855
  if (!this._messages) return;
1847
1856
  var messages = Faye.map(this._messages, function(id, msg) { return msg });
@@ -1852,17 +1861,17 @@ Faye.Transport.WebSocket = Faye.extend(Faye.Class(Faye.Transport, {
1852
1861
  if (Faye.URI) endpoint = Faye.URI.parse(endpoint).toURL();
1853
1862
  return endpoint.replace(/^http(s?):/ig, 'ws$1:');
1854
1863
  },
1855
-
1864
+
1856
1865
  getClass: function() {
1857
1866
  return (Faye.WebSocket && Faye.WebSocket.Client) ||
1858
1867
  Faye.ENV.WebSocket ||
1859
1868
  Faye.ENV.MozWebSocket;
1860
1869
  },
1861
-
1870
+
1862
1871
  isUsable: function(client, endpoint, callback, context) {
1863
1872
  this.create(client, endpoint).isUsable(callback, context);
1864
1873
  },
1865
-
1874
+
1866
1875
  create: function(client, endpoint) {
1867
1876
  var sockets = client.transports.websocket = client.transports.websocket || {};
1868
1877
  sockets[endpoint] = sockets[endpoint] || new this(client, endpoint);
@@ -1883,18 +1892,18 @@ Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
1883
1892
  initialize: function(client, endpoint) {
1884
1893
  Faye.Transport.prototype.initialize.call(this, client, endpoint);
1885
1894
  if (!Faye.ENV.EventSource) return this.setDeferredStatus('failed');
1886
-
1895
+
1887
1896
  this._xhr = new Faye.Transport.XHR(client, endpoint);
1888
-
1897
+
1889
1898
  var socket = new EventSource(endpoint + '/' + client.getClientId()),
1890
1899
  self = this;
1891
-
1900
+
1892
1901
  socket.onopen = function() {
1893
1902
  self._everConnected = true;
1894
1903
  self.setDeferredStatus('succeeded');
1895
1904
  self.trigger('up');
1896
1905
  };
1897
-
1906
+
1898
1907
  socket.onerror = function() {
1899
1908
  if (self._everConnected) {
1900
1909
  self.trigger('down');
@@ -1903,40 +1912,46 @@ Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
1903
1912
  socket.close();
1904
1913
  }
1905
1914
  };
1906
-
1915
+
1907
1916
  socket.onmessage = function(event) {
1908
1917
  self.receive(JSON.parse(event.data));
1909
1918
  self.trigger('up');
1910
1919
  };
1911
-
1920
+
1912
1921
  this._socket = socket;
1913
1922
  },
1914
-
1923
+
1915
1924
  isUsable: function(callback, context) {
1916
1925
  this.callback(function() { callback.call(context, true) });
1917
1926
  this.errback(function() { callback.call(context, false) });
1918
1927
  },
1919
-
1928
+
1920
1929
  request: function(message, timeout) {
1921
1930
  this._xhr.request(message, timeout);
1922
1931
  },
1923
-
1932
+
1924
1933
  close: function() {
1934
+ if (!this._socket) return;
1935
+ this._socket.onerror = null;
1925
1936
  this._socket.close();
1937
+ delete this._socket;
1926
1938
  }
1927
1939
  }), {
1928
1940
  isUsable: function(client, endpoint, callback, context) {
1929
1941
  var id = client.getClientId();
1930
1942
  if (!id) return callback.call(context, false);
1931
-
1943
+
1932
1944
  Faye.Transport.XHR.isUsable(client, endpoint, function(usable) {
1933
1945
  if (!usable) return callback.call(context, false);
1934
1946
  this.create(client, endpoint).isUsable(callback, context);
1935
1947
  }, this);
1936
1948
  },
1937
-
1949
+
1938
1950
  create: function(client, endpoint) {
1939
- var sockets = client.transports.eventsource = client.transports.eventsource || {};
1951
+ var sockets = client.transports.eventsource = client.transports.eventsource || {},
1952
+ id = client.getClientId(),
1953
+ endpoint = endpoint + '/' + (id || '');
1954
+
1940
1955
  sockets[endpoint] = sockets[endpoint] || new this(client, endpoint);
1941
1956
  return sockets[endpoint];
1942
1957
  }
@@ -1954,48 +1969,48 @@ Faye.Transport.XHR = Faye.extend(Faye.Class(Faye.Transport, {
1954
1969
  xhr = Faye.ENV.ActiveXObject
1955
1970
  ? new ActiveXObject("Microsoft.XMLHTTP")
1956
1971
  : new XMLHttpRequest();
1957
-
1972
+
1958
1973
  xhr.open('POST', path, true);
1959
1974
  xhr.setRequestHeader('Content-Type', 'application/json');
1960
1975
  xhr.setRequestHeader('Pragma', 'no-cache');
1961
1976
  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
1962
-
1977
+
1963
1978
  var headers = this.headers;
1964
1979
  for (var key in headers) {
1965
1980
  if (!headers.hasOwnProperty(key)) continue;
1966
1981
  xhr.setRequestHeader(key, headers[key]);
1967
1982
  }
1968
-
1983
+
1969
1984
  var abort = function() { xhr.abort() };
1970
1985
  Faye.Event.on(Faye.ENV, 'beforeunload', abort);
1971
-
1986
+
1972
1987
  var cleanUp = function() {
1973
1988
  Faye.Event.detach(Faye.ENV, 'beforeunload', abort);
1974
1989
  xhr.onreadystatechange = function() {};
1975
1990
  xhr = null;
1976
1991
  };
1977
-
1992
+
1978
1993
  xhr.onreadystatechange = function() {
1979
1994
  if (xhr.readyState !== 4) return;
1980
-
1995
+
1981
1996
  var parsedMessage = null,
1982
1997
  status = xhr.status,
1983
1998
  successful = ((status >= 200 && status < 300) ||
1984
1999
  status === 304 ||
1985
2000
  status === 1223);
1986
-
2001
+
1987
2002
  if (!successful) {
1988
2003
  cleanUp();
1989
2004
  retry();
1990
2005
  return self.trigger('down');
1991
2006
  }
1992
-
2007
+
1993
2008
  try {
1994
2009
  parsedMessage = JSON.parse(xhr.responseText);
1995
2010
  } catch (e) {}
1996
-
2011
+
1997
2012
  cleanUp();
1998
-
2013
+
1999
2014
  if (parsedMessage) {
2000
2015
  self.receive(parsedMessage);
2001
2016
  self.trigger('up');
@@ -2021,10 +2036,10 @@ Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2021
2036
  xhr = new xhrClass(),
2022
2037
  retry = this.retry(message, timeout),
2023
2038
  self = this;
2024
-
2039
+
2025
2040
  xhr.open('POST', this.endpoint, true);
2026
2041
  if (xhr.setRequestHeader) xhr.setRequestHeader('Pragma', 'no-cache');
2027
-
2042
+
2028
2043
  var cleanUp = function() {
2029
2044
  if (!xhr) return false;
2030
2045
  xhr.onload = xhr.onerror = xhr.ontimeout = xhr.onprogress = null;
@@ -2032,15 +2047,15 @@ Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2032
2047
  Faye.ENV.clearTimeout(timer);
2033
2048
  return true;
2034
2049
  };
2035
-
2050
+
2036
2051
  xhr.onload = function() {
2037
2052
  var parsedMessage = null;
2038
2053
  try {
2039
2054
  parsedMessage = JSON.parse(xhr.responseText);
2040
2055
  } catch (e) {}
2041
-
2056
+
2042
2057
  cleanUp();
2043
-
2058
+
2044
2059
  if (parsedMessage) {
2045
2060
  self.receive(parsedMessage);
2046
2061
  self.trigger('up');
@@ -2049,7 +2064,7 @@ Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2049
2064
  self.trigger('down');
2050
2065
  }
2051
2066
  };
2052
-
2067
+
2053
2068
  var onerror = function() {
2054
2069
  cleanUp();
2055
2070
  retry();
@@ -2058,7 +2073,7 @@ Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2058
2073
  var timer = Faye.ENV.setTimeout(onerror, 1.5 * 1000 * timeout);
2059
2074
  xhr.onerror = onerror;
2060
2075
  xhr.ontimeout = onerror;
2061
-
2076
+
2062
2077
  xhr.onprogress = function() {};
2063
2078
  xhr.send('message=' + encodeURIComponent(Faye.toJSON(message)));
2064
2079
  }
@@ -2066,11 +2081,11 @@ Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
2066
2081
  isUsable: function(client, endpoint, callback, context) {
2067
2082
  if (Faye.URI.parse(endpoint).isSameOrigin())
2068
2083
  return callback.call(context, false);
2069
-
2084
+
2070
2085
  if (Faye.ENV.XDomainRequest)
2071
2086
  return callback.call(context, Faye.URI.parse(endpoint).protocol ===
2072
2087
  Faye.URI.parse(Faye.ENV.location).protocol);
2073
-
2088
+
2074
2089
  if (Faye.ENV.XMLHttpRequest) {
2075
2090
  var xhr = new Faye.ENV.XMLHttpRequest();
2076
2091
  return callback.call(context, xhr.withCredentials !== undefined);
@@ -2091,7 +2106,7 @@ Faye.Transport.JSONP = Faye.extend(Faye.Class(Faye.Transport, {
2091
2106
  var location = Faye.URI.parse(this.endpoint, params).toURL();
2092
2107
  return location.length >= Faye.Transport.MAX_URL_LENGTH;
2093
2108
  },
2094
-
2109
+
2095
2110
  request: function(messages, timeout) {
2096
2111
  var params = {message: Faye.toJSON(messages)},
2097
2112
  head = document.getElementsByTagName('head')[0],
@@ -2100,19 +2115,19 @@ Faye.Transport.JSONP = Faye.extend(Faye.Class(Faye.Transport, {
2100
2115
  location = Faye.URI.parse(this.endpoint, params),
2101
2116
  retry = this.retry(messages, timeout),
2102
2117
  self = this;
2103
-
2118
+
2104
2119
  Faye.ENV[callbackName] = function(data) {
2105
2120
  cleanUp();
2106
2121
  self.receive(data);
2107
2122
  self.trigger('up');
2108
2123
  };
2109
-
2124
+
2110
2125
  var timer = Faye.ENV.setTimeout(function() {
2111
2126
  cleanUp();
2112
2127
  retry();
2113
2128
  self.trigger('down');
2114
2129
  }, 1.5 * 1000 * timeout);
2115
-
2130
+
2116
2131
  var cleanUp = function() {
2117
2132
  if (!Faye.ENV[callbackName]) return false;
2118
2133
  Faye.ENV[callbackName] = undefined;
@@ -2121,7 +2136,7 @@ Faye.Transport.JSONP = Faye.extend(Faye.Class(Faye.Transport, {
2121
2136
  script.parentNode.removeChild(script);
2122
2137
  return true;
2123
2138
  };
2124
-
2139
+
2125
2140
  location.params.jsonp = callbackName;
2126
2141
  script.type = 'text/javascript';
2127
2142
  script.src = location.toURL();
@@ -2129,12 +2144,12 @@ Faye.Transport.JSONP = Faye.extend(Faye.Class(Faye.Transport, {
2129
2144
  }
2130
2145
  }), {
2131
2146
  _cbCount: 0,
2132
-
2147
+
2133
2148
  getCallbackName: function() {
2134
2149
  this._cbCount += 1;
2135
2150
  return '__jsonp' + this._cbCount + '__';
2136
2151
  },
2137
-
2152
+
2138
2153
  isUsable: function(client, endpoint, callback, context) {
2139
2154
  callback.call(context, true);
2140
2155
  }