faye 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of faye might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +14 -4
- data/README.md +1 -1
- data/build/client/faye-browser-min.js +3 -0
- data/build/client/faye-browser-min.js.map +1 -0
- data/build/client/faye-browser.js +3017 -0
- data/build/client/faye-browser.js.map +1 -0
- data/lib/faye.rb +1 -1
- data/lib/faye/adapters/rack_adapter.rb +9 -4
- data/lib/faye/protocol/channel.rb +5 -5
- data/lib/faye/protocol/client.rb +10 -9
- data/lib/faye/protocol/server.rb +4 -12
- data/lib/faye/protocol/subscription.rb +17 -1
- data/lib/faye/transport/http.rb +4 -1
- data/lib/faye/transport/local.rb +4 -2
- data/lib/faye/transport/transport.rb +16 -6
- data/lib/faye/transport/web_socket.rb +14 -10
- metadata +9 -7
- data/lib/faye-browser-min.js +0 -2
- data/lib/faye-browser-min.js.map +0 -1
- data/lib/faye-browser.js +0 -2774
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap 15f36c39af4f607b524f","webpack:///./src/faye_browser.js","webpack:///./src/util/constants.js","webpack:///./src/mixins/logging.js","webpack:///./src/util/to_json.js","webpack:///./src/protocol/client.js","webpack:///./~/asap/browser-asap.js","webpack:///./~/asap/browser-raw.js","webpack:///./src/util/class.js","webpack:///./src/util/extend.js","webpack:///./src/util/promise.js","webpack:///./src/util/uri.js","webpack:///./src/util/array.js","webpack:///./src/util/browser/event.js","webpack:///./src/util/validate_options.js","webpack:///./src/mixins/deferrable.js","webpack:///./src/mixins/publisher.js","webpack:///./src/util/event_emitter.js","webpack:///./src/protocol/channel.js","webpack:///./src/protocol/grammar.js","webpack:///./src/protocol/dispatcher.js","webpack:///./src/util/cookies/browser_cookies.js","webpack:///./src/transport/browser_transports.js","webpack:///./src/transport/transport.js","webpack:///./src/mixins/timeouts.js","webpack:///./src/transport/web_socket.js","webpack:///./src/util/set.js","webpack:///./src/util/copy_object.js","webpack:///./src/util/websocket/browser_websocket.js","webpack:///./src/transport/event_source.js","webpack:///./src/transport/xhr.js","webpack:///./src/transport/cors.js","webpack:///./src/transport/jsonp.js","webpack:///./src/protocol/scheduler.js","webpack:///./src/protocol/error.js","webpack:///./src/protocol/extensible.js","webpack:///./src/protocol/publication.js","webpack:///./src/protocol/subscription.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;;;;;;ACdA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;ACTA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA,UAAS;;AAET;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;;;;;;;AC9CA;;AAEA;;AAEA;AACA;AACA;AACA,IAAG;AACH;;;;;;;ACRA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,qBAAoB;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,QAAO;AACP,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,MAAK,IAAI;;AAET;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA,wCAAuC,yBAAyB;;AAEhE,QAAO;AACP;AACA,uCAAsC,oCAAoC;AAC1E;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yCAAwC,kCAAkC;;AAE1E;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA,MAAK,IAAI;AACT,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,MAAK,IAAI;AACT;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,MAAK;;AAEL;AACA;;AAEA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;;AAEP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,QAAO,IAAI;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;;AAEP;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,QAAO,IAAI;AACX;;AAEA;AACA;AACA,QAAO;AACP,MAAK;AACL,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAiC;AACjC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,QAAO;AACP;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,mEAAkE;AAClE,MAAK;AACL,IAAG;;AAEH;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,mCAAkC,iBAAiB;AACnD;AACA,EAAC;;AAED;AACA;AACA;AACA;;AAEA;;;;;;;;ACjYA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAY,MAAM;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;;;;;;ACjEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAgE,kBAAkB;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA4B,oBAAoB;AAChD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC3NA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtBA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACXA;;AAEA;;AAEA;AACA;AACA;;AAEA,2BAA0B,WAAW;AACrC,2BAA0B;;AAE1B;AACA;AACA;AACA;;AAEA;AACA;;AAEA,0BAAyB,uBAAuB;AAChD,0BAAyB,uBAAuB;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,kCAAiC;;AAEjC;AACA;AACA,IAAG;AACH;AACA;AACA;;AAEA;AACA;AACA,mCAAkC;;AAElC;AACA;AACA,IAAG;AACH;AACA;AACA;;AAEA;AACA,oBAAmB,2BAA2B;AAC9C;;AAEA;AACA;;AAEA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA,IAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL,IAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iDAAgD,iBAAiB;AACjE;;AAEA;AACA,iDAAgD,iBAAiB;AACjE;;AAEA;AACA;AACA;;AAEA;;AAEA,gBAAe,OAAO;AACtB;AACA;AACA;AACA,QAAO;AACP,MAAK;AACL,IAAG;AACH;;AAEA;AACA;AACA,yCAAwC,OAAO;AAC/C;AACA,IAAG;AACH;;AAEA;AACA;;AAEA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;;;;;;;AChKA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,iBAAgB;;AAEhB;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,kCAAiC,OAAO;AACxC;AACA;AACA;;AAEA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AClFA;;AAEA;AACA;AACA,sCAAqC,OAAO;AAC5C;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;AAEA,qCAAoC,OAAO;AAC3C;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA,yCAAwC,OAAO;AAC/C;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,sCAAqC,OAAO;AAC5C;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACzEA;;AAEA;AACA;;AAEA;AACA,+BAA8B;;AAE9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;;;;;;ACjDA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACTA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA,uCAAsC,gCAAgC;AACtE,IAAG;;AAEH;AACA,8CAA6C,iCAAiC;AAC9E,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC/CA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,+BAA8B;;AAE9B;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAmB,eAAe;AAClC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA2B;AAC3B,QAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAG;AACH;;AAEA;AACA,0CAAyC,OAAO;AAChD;AACA;AACA;;AAEA,IAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA,IAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC1KA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,EAAC;;AAED;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,yCAAwC,OAAO;AAC/C;AACA;AACA;AACA;;AAEA;AACA,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA,MAAK;;AAEL;AACA;AACA,MAAK;;AAEL;AACA;AACA,wCAAuC,OAAO;AAC9C;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,MAAK;;AAEL;AACA;;AAEA,2CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA,IAAG;AACH,EAAC;;AAED;;;;;;;ACnIA;;AAEA;AACA;AACA,qFAAoF,IAAI;AACxF;AACA;AACA;;;;;;;ACPA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yBAAwB;AACxB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yDAAwD;;AAExD;AACA;AACA;AACA,uCAAsC,OAAO;AAC7C;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,iDAAgD,+EAA+E;AAC/H,0CAAyC;AACzC;;AAEA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAK;;AAEL;AACA;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,MAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,EAAC;;AAED;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACxLA;;AAEA;;;;;;;ACFA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,+BAA8B;AAC9B,sBAAqB,mDAAmD;AACxE;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,iCAAgC;;AAEhC;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH,uBAAsB;;AAEtB;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,MAAK;;AAEL;AACA,IAAG;;AAEH;AACA;;AAEA;AACA,sCAAqC;;AAErC;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA,wCAAuC,OAAO;AAC9C;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;;AAEA,yCAAwC,OAAO;AAC/C;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;AACA,MAAK,SAAS;AACd,IAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA,0CAAyC,OAAO;AAChD;AACA;AACA;AACA;;AAEA,EAAC;AACD;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,+DAA8D;AAC9D;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;AACL;AACA,MAAK;AACL,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA,qDAAoD,cAAc;AAClE,IAAG;;AAEH;AACA,EAAC;;AAED;AACA;;AAEA;;;;;;;ACzLA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;;;;;;;;ACzBA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,+BAA8B,+BAA+B;AAC7D,8BAA6B,gCAAgC;AAC7D;AACA,IAAG;;AAEH;AACA;AACA,yCAAwC,OAAO;;AAE/C;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAO;;AAEP;AACA,MAAK;;AAEL;AACA,0BAAyB,4BAA4B,aAAa;AAClE;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;;AAEA;AACA;AACA,YAAW,mCAAmC;;AAE9C;;AAEA;;AAEA,0CAAyC,OAAO;AAChD;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,uBAAsB;;AAEtB;;AAEA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA,EAAC;AACD;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,EAAC;;AAED;;AAEA;AACA,wDAAuD,6BAA6B;;AAEpF;;;;;;;;AChKA;;AAEA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,kCAAiC,mBAAmB;AACpD;AACA;AACA,EAAC;;;;;;;ACjDD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;;AAEA;;;;;;;AClBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;ACRA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAW,mCAAmC;;AAE9C;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA,+BAA8B,+BAA+B;AAC7D,8BAA6B,gCAAgC;AAC7D,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA,EAAC;AACD;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL,IAAG;;AAEH;AACA,8FAA6F;AAC7F;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAC;;AAED;;AAEA;;;;;;;;AChGA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,6BAA4B;AAC5B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,EAAC;;AAED;;;;;;;;ACjFA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAW,yCAAyC;;AAEpD;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,0BAAyB,iBAAiB;;AAE1C;AACA;AACA;AACA,EAAC;AACD;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;;AAED;;;;;;;;ACnFA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,YAAW,8BAA8B;AACzC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,aAAY;AACZ;AACA,EAAC;AACD;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,EAAC;;AAED;;;;;;;;AC/DA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH,yBAAwB;;AAExB,sBAAqB;;AAErB;AACA,EAAC;;AAED;;;;;;;AC7CA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,EAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;;;;;;;ACtDA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;AC9CA;;AAEA;AACA;;AAEA;;;;;;;ACLA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,EAAC;;AAED;;AAEA","file":"faye-browser.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 15f36c39af4f607b524f\n **/","'use strict';\n\nvar constants = require('./util/constants'),\n Logging = require('./mixins/logging');\n\nvar Faye = {\n VERSION: constants.VERSION,\n\n Client: require('./protocol/client'),\n Scheduler: require('./protocol/scheduler')\n};\n\nLogging.wrapper = Faye;\n\nmodule.exports = Faye;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/faye_browser.js\n ** module id = 0\n ** module chunks = 0\n **/","module.exports = {\n VERSION: '1.2.0',\n\n BAYEUX_VERSION: '1.0',\n ID_LENGTH: 160,\n JSONP_CALLBACK: 'jsonpcallback',\n CONNECTION_TYPES: ['long-polling', 'cross-origin-long-polling', 'callback-polling', 'websocket', 'eventsource', 'in-process'],\n\n MANDATORY_CONNECTION_TYPES: ['long-polling', 'callback-polling', 'in-process']\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/constants.js\n ** module id = 1\n ** module chunks = 0\n **/","'use strict';\n\nvar toJSON = require('../util/to_json');\n\nvar Logging = {\n LOG_LEVELS: {\n fatal: 4,\n error: 3,\n warn: 2,\n info: 1,\n debug: 0\n },\n\n writeLog: function(messageArgs, level) {\n var logger = Logging.logger || (Logging.wrapper || Logging).logger;\n if (!logger) return;\n\n var args = Array.prototype.slice.apply(messageArgs),\n banner = '[Faye',\n klass = this.className,\n\n message = args.shift().replace(/\\?/g, function() {\n try {\n return toJSON(args.shift());\n } catch (error) {\n return '[Object]';\n }\n });\n\n if (klass) banner += '.' + klass;\n banner += '] ';\n\n if (typeof logger[level] === 'function')\n logger[level](banner + message);\n else if (typeof logger === 'function')\n logger(banner + message);\n }\n};\n\nfor (var key in Logging.LOG_LEVELS)\n (function(level) {\n Logging[level] = function() {\n this.writeLog(arguments, level);\n };\n })(key);\n\nmodule.exports = Logging;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/mixins/logging.js\n ** module id = 2\n ** module chunks = 0\n **/","'use strict';\n\n// http://assanka.net/content/tech/2009/09/02/json2-js-vs-prototype/\n\nmodule.exports = function(object) {\n return JSON.stringify(object, function(key, value) {\n return (this[key] instanceof Array) ? this[key] : value;\n });\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/to_json.js\n ** module id = 3\n ** module chunks = 0\n **/","'use strict';\n\nvar asap = require('asap'),\n Class = require('../util/class'),\n Promise = require('../util/promise'),\n URI = require('../util/uri'),\n array = require('../util/array'),\n browser = require('../util/browser'),\n constants = require('../util/constants'),\n extend = require('../util/extend'),\n validateOptions = require('../util/validate_options'),\n Deferrable = require('../mixins/deferrable'),\n Logging = require('../mixins/logging'),\n Publisher = require('../mixins/publisher'),\n Channel = require('./channel'),\n Dispatcher = require('./dispatcher'),\n Error = require('./error'),\n Extensible = require('./extensible'),\n Publication = require('./publication'),\n Subscription = require('./subscription');\n\nvar Client = Class({ className: 'Client',\n UNCONNECTED: 1,\n CONNECTING: 2,\n CONNECTED: 3,\n DISCONNECTED: 4,\n\n HANDSHAKE: 'handshake',\n RETRY: 'retry',\n NONE: 'none',\n\n CONNECTION_TIMEOUT: 60,\n\n DEFAULT_ENDPOINT: '/bayeux',\n INTERVAL: 0,\n\n initialize: function(endpoint, options) {\n this.info('New client created for ?', endpoint);\n options = options || {};\n\n validateOptions(options, ['interval', 'timeout', 'endpoints', 'proxy', 'retry', 'scheduler', 'websocketExtensions', 'tls', 'ca']);\n\n this._channels = new Channel.Set();\n this._dispatcher = Dispatcher.create(this, endpoint || this.DEFAULT_ENDPOINT, options);\n\n this._messageId = 0;\n this._state = this.UNCONNECTED;\n\n this._responseCallbacks = {};\n\n this._advice = {\n reconnect: this.RETRY,\n interval: 1000 * (options.interval || this.INTERVAL),\n timeout: 1000 * (options.timeout || this.CONNECTION_TIMEOUT)\n };\n this._dispatcher.timeout = this._advice.timeout / 1000;\n\n this._dispatcher.bind('message', this._receiveMessage, this);\n\n if (browser.Event && global.onbeforeunload !== undefined)\n browser.Event.on(global, 'beforeunload', function() {\n if (array.indexOf(this._dispatcher._disabled, 'autodisconnect') < 0)\n this.disconnect();\n }, this);\n },\n\n addWebsocketExtension: function(extension) {\n return this._dispatcher.addWebsocketExtension(extension);\n },\n\n disable: function(feature) {\n return this._dispatcher.disable(feature);\n },\n\n setHeader: function(name, value) {\n return this._dispatcher.setHeader(name, value);\n },\n\n // Request\n // MUST include: * channel\n // * version\n // * supportedConnectionTypes\n // MAY include: * minimumVersion\n // * ext\n // * id\n //\n // Success Response Failed Response\n // MUST include: * channel MUST include: * channel\n // * version * successful\n // * supportedConnectionTypes * error\n // * clientId MAY include: * supportedConnectionTypes\n // * successful * advice\n // MAY include: * minimumVersion * version\n // * advice * minimumVersion\n // * ext * ext\n // * id * id\n // * authSuccessful\n handshake: function(callback, context) {\n if (this._advice.reconnect === this.NONE) return;\n if (this._state !== this.UNCONNECTED) return;\n\n this._state = this.CONNECTING;\n var self = this;\n\n this.info('Initiating handshake with ?', URI.stringify(this._dispatcher.endpoint));\n this._dispatcher.selectTransport(constants.MANDATORY_CONNECTION_TYPES);\n\n this._sendMessage({\n channel: Channel.HANDSHAKE,\n version: constants.BAYEUX_VERSION,\n supportedConnectionTypes: this._dispatcher.getConnectionTypes()\n\n }, {}, function(response) {\n\n if (response.successful) {\n this._state = this.CONNECTED;\n this._dispatcher.clientId = response.clientId;\n\n this._dispatcher.selectTransport(response.supportedConnectionTypes);\n\n this.info('Handshake successful: ?', this._dispatcher.clientId);\n\n this.subscribe(this._channels.getKeys(), true);\n if (callback) asap(function() { callback.call(context) });\n\n } else {\n this.info('Handshake unsuccessful');\n global.setTimeout(function() { self.handshake(callback, context) }, this._dispatcher.retry * 1000);\n this._state = this.UNCONNECTED;\n }\n }, this);\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // * connectionType * clientId\n // MAY include: * ext MAY include: * error\n // * id * advice\n // * ext\n // * id\n // * timestamp\n connect: function(callback, context) {\n if (this._advice.reconnect === this.NONE) return;\n if (this._state === this.DISCONNECTED) return;\n\n if (this._state === this.UNCONNECTED)\n return this.handshake(function() { this.connect(callback, context) }, this);\n\n this.callback(callback, context);\n if (this._state !== this.CONNECTED) return;\n\n this.info('Calling deferred actions for ?', this._dispatcher.clientId);\n this.setDeferredStatus('succeeded');\n this.setDeferredStatus('unknown');\n\n if (this._connectRequest) return;\n this._connectRequest = true;\n\n this.info('Initiating connection for ?', this._dispatcher.clientId);\n\n this._sendMessage({\n channel: Channel.CONNECT,\n clientId: this._dispatcher.clientId,\n connectionType: this._dispatcher.connectionType\n\n }, {}, this._cycleConnection, this);\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // MAY include: * ext * clientId\n // * id MAY include: * error\n // * ext\n // * id\n disconnect: function() {\n if (this._state !== this.CONNECTED) return;\n this._state = this.DISCONNECTED;\n\n this.info('Disconnecting ?', this._dispatcher.clientId);\n var promise = new Publication();\n\n this._sendMessage({\n channel: Channel.DISCONNECT,\n clientId: this._dispatcher.clientId\n\n }, {}, function(response) {\n if (response.successful) {\n this._dispatcher.close();\n promise.setDeferredStatus('succeeded');\n } else {\n promise.setDeferredStatus('failed', Error.parse(response.error));\n }\n }, this);\n\n this.info('Clearing channel listeners for ?', this._dispatcher.clientId);\n this._channels = new Channel.Set();\n\n return promise;\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // * subscription * clientId\n // MAY include: * ext * subscription\n // * id MAY include: * error\n // * advice\n // * ext\n // * id\n // * timestamp\n subscribe: function(channel, callback, context) {\n if (channel instanceof Array)\n return array.map(channel, function(c) {\n return this.subscribe(c, callback, context);\n }, this);\n\n var subscription = new Subscription(this, channel, callback, context),\n force = (callback === true),\n hasSubscribe = this._channels.hasSubscription(channel);\n\n if (hasSubscribe && !force) {\n this._channels.subscribe([channel], subscription);\n subscription.setDeferredStatus('succeeded');\n return subscription;\n }\n\n this.connect(function() {\n this.info('Client ? attempting to subscribe to ?', this._dispatcher.clientId, channel);\n if (!force) this._channels.subscribe([channel], subscription);\n\n this._sendMessage({\n channel: Channel.SUBSCRIBE,\n clientId: this._dispatcher.clientId,\n subscription: channel\n\n }, {}, function(response) {\n if (!response.successful) {\n subscription.setDeferredStatus('failed', Error.parse(response.error));\n return this._channels.unsubscribe(channel, subscription);\n }\n\n var channels = [].concat(response.subscription);\n this.info('Subscription acknowledged for ? to ?', this._dispatcher.clientId, channels);\n subscription.setDeferredStatus('succeeded');\n }, this);\n }, this);\n\n return subscription;\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // * subscription * clientId\n // MAY include: * ext * subscription\n // * id MAY include: * error\n // * advice\n // * ext\n // * id\n // * timestamp\n unsubscribe: function(channel, subscription) {\n if (channel instanceof Array)\n return array.map(channel, function(c) {\n return this.unsubscribe(c, subscription);\n }, this);\n\n var dead = this._channels.unsubscribe(channel, subscription);\n if (!dead) return;\n\n this.connect(function() {\n this.info('Client ? attempting to unsubscribe from ?', this._dispatcher.clientId, channel);\n\n this._sendMessage({\n channel: Channel.UNSUBSCRIBE,\n clientId: this._dispatcher.clientId,\n subscription: channel\n\n }, {}, function(response) {\n if (!response.successful) return;\n\n var channels = [].concat(response.subscription);\n this.info('Unsubscription acknowledged for ? from ?', this._dispatcher.clientId, channels);\n }, this);\n }, this);\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * data * successful\n // MAY include: * clientId MAY include: * id\n // * id * error\n // * ext * ext\n publish: function(channel, data, options) {\n validateOptions(options || {}, ['attempts', 'deadline']);\n var publication = new Publication();\n\n this.connect(function() {\n this.info('Client ? queueing published message to ?: ?', this._dispatcher.clientId, channel, data);\n\n this._sendMessage({\n channel: channel,\n data: data,\n clientId: this._dispatcher.clientId\n\n }, options, function(response) {\n if (response.successful)\n publication.setDeferredStatus('succeeded');\n else\n publication.setDeferredStatus('failed', Error.parse(response.error));\n }, this);\n }, this);\n\n return publication;\n },\n\n _sendMessage: function(message, options, callback, context) {\n message.id = this._generateMessageId();\n\n var timeout = this._advice.timeout\n ? 1.2 * this._advice.timeout / 1000\n : 1.2 * this._dispatcher.retry;\n\n this.pipeThroughExtensions('outgoing', message, null, function(message) {\n if (!message) return;\n if (callback) this._responseCallbacks[message.id] = [callback, context];\n this._dispatcher.sendMessage(message, timeout, options || {});\n }, this);\n },\n\n _generateMessageId: function() {\n this._messageId += 1;\n if (this._messageId >= Math.pow(2,32)) this._messageId = 0;\n return this._messageId.toString(36);\n },\n\n _receiveMessage: function(message) {\n var id = message.id, callback;\n\n if (message.successful !== undefined) {\n callback = this._responseCallbacks[id];\n delete this._responseCallbacks[id];\n }\n\n this.pipeThroughExtensions('incoming', message, null, function(message) {\n if (!message) return;\n if (message.advice) this._handleAdvice(message.advice);\n this._deliverMessage(message);\n if (callback) callback[0].call(callback[1], message);\n }, this);\n },\n\n _handleAdvice: function(advice) {\n extend(this._advice, advice);\n this._dispatcher.timeout = this._advice.timeout / 1000;\n\n if (this._advice.reconnect === this.HANDSHAKE && this._state !== this.DISCONNECTED) {\n this._state = this.UNCONNECTED;\n this._dispatcher.clientId = null;\n this._cycleConnection();\n }\n },\n\n _deliverMessage: function(message) {\n if (!message.channel || message.data === undefined) return;\n this.info('Client ? calling listeners for ? with ?', this._dispatcher.clientId, message.channel, message.data);\n this._channels.distributeMessage(message);\n },\n\n _cycleConnection: function() {\n if (this._connectRequest) {\n this._connectRequest = null;\n this.info('Closed connection for ?', this._dispatcher.clientId);\n }\n var self = this;\n global.setTimeout(function() { self.connect() }, this._advice.interval);\n }\n});\n\nextend(Client.prototype, Deferrable);\nextend(Client.prototype, Publisher);\nextend(Client.prototype, Logging);\nextend(Client.prototype, Extensible);\n\nmodule.exports = Client;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/client.js\n ** module id = 4\n ** module chunks = 0\n **/","\"use strict\";\n\n// rawAsap provides everything we need except exception management.\nvar rawAsap = require(\"./raw\");\n// RawTasks are recycled to reduce GC churn.\nvar freeTasks = [];\n// We queue errors to ensure they are thrown in right order (FIFO).\n// Array-as-queue is good enough here, since we are just dealing with exceptions.\nvar pendingErrors = [];\nvar requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError);\n\nfunction throwFirstError() {\n if (pendingErrors.length) {\n throw pendingErrors.shift();\n }\n}\n\n/**\n * Calls a task as soon as possible after returning, in its own event, with priority\n * over other events like animation, reflow, and repaint. An error thrown from an\n * event will not interrupt, nor even substantially slow down the processing of\n * other events, but will be rather postponed to a lower priority event.\n * @param {{call}} task A callable object, typically a function that takes no\n * arguments.\n */\nmodule.exports = asap;\nfunction asap(task) {\n var rawTask;\n if (freeTasks.length) {\n rawTask = freeTasks.pop();\n } else {\n rawTask = new RawTask();\n }\n rawTask.task = task;\n rawAsap(rawTask);\n}\n\n// We wrap tasks with recyclable task objects. A task object implements\n// `call`, just like a function.\nfunction RawTask() {\n this.task = null;\n}\n\n// The sole purpose of wrapping the task is to catch the exception and recycle\n// the task object after its single use.\nRawTask.prototype.call = function () {\n try {\n this.task.call();\n } catch (error) {\n if (asap.onerror) {\n // This hook exists purely for testing purposes.\n // Its name will be periodically randomized to break any code that\n // depends on its existence.\n asap.onerror(error);\n } else {\n // In a web browser, exceptions are not fatal. However, to avoid\n // slowing down the queue of pending tasks, we rethrow the error in a\n // lower priority turn.\n pendingErrors.push(error);\n requestErrorThrow();\n }\n } finally {\n this.task = null;\n freeTasks[freeTasks.length] = this;\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/asap/browser-asap.js\n ** module id = 5\n ** module chunks = 0\n **/","\"use strict\";\n\n// Use the fastest means possible to execute a task in its own turn, with\n// priority over other events including IO, animation, reflow, and redraw\n// events in browsers.\n//\n// An exception thrown by a task will permanently interrupt the processing of\n// subsequent tasks. The higher level `asap` function ensures that if an\n// exception is thrown by a task, that the task queue will continue flushing as\n// soon as possible, but if you use `rawAsap` directly, you are responsible to\n// either ensure that no exceptions are thrown from your task, or to manually\n// call `rawAsap.requestFlush` if an exception is thrown.\nmodule.exports = rawAsap;\nfunction rawAsap(task) {\n if (!queue.length) {\n requestFlush();\n flushing = true;\n }\n // Equivalent to push, but avoids a function call.\n queue[queue.length] = task;\n}\n\nvar queue = [];\n// Once a flush has been requested, no further calls to `requestFlush` are\n// necessary until the next `flush` completes.\nvar flushing = false;\n// `requestFlush` is an implementation-specific method that attempts to kick\n// off a `flush` event as quickly as possible. `flush` will attempt to exhaust\n// the event queue before yielding to the browser's own event loop.\nvar requestFlush;\n// The position of the next task to execute in the task queue. This is\n// preserved between calls to `flush` so that it can be resumed if\n// a task throws an exception.\nvar index = 0;\n// If a task schedules additional tasks recursively, the task queue can grow\n// unbounded. To prevent memory exhaustion, the task queue will periodically\n// truncate already-completed tasks.\nvar capacity = 1024;\n\n// The flush function processes all tasks that have been scheduled with\n// `rawAsap` unless and until one of those tasks throws an exception.\n// If a task throws an exception, `flush` ensures that its state will remain\n// consistent and will resume where it left off when called again.\n// However, `flush` does not make any arrangements to be called again if an\n// exception is thrown.\nfunction flush() {\n while (index < queue.length) {\n var currentIndex = index;\n // Advance the index before calling the task. This ensures that we will\n // begin flushing on the next task the task throws an error.\n index = index + 1;\n queue[currentIndex].call();\n // Prevent leaking memory for long chains of recursive calls to `asap`.\n // If we call `asap` within tasks scheduled by `asap`, the queue will\n // grow, but to avoid an O(n) walk for every task we execute, we don't\n // shift tasks off the queue after they have been executed.\n // Instead, we periodically shift 1024 tasks off the queue.\n if (index > capacity) {\n // Manually shift all values starting at the index back to the\n // beginning of the queue.\n for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {\n queue[scan] = queue[scan + index];\n }\n queue.length -= index;\n index = 0;\n }\n }\n queue.length = 0;\n index = 0;\n flushing = false;\n}\n\n// `requestFlush` is implemented using a strategy based on data collected from\n// every available SauceLabs Selenium web driver worker at time of writing.\n// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593\n\n// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that\n// have WebKitMutationObserver but not un-prefixed MutationObserver.\n// Must use `global` instead of `window` to work in both frames and web\n// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.\nvar BrowserMutationObserver = global.MutationObserver || global.WebKitMutationObserver;\n\n// MutationObservers are desirable because they have high priority and work\n// reliably everywhere they are implemented.\n// They are implemented in all modern browsers.\n//\n// - Android 4-4.3\n// - Chrome 26-34\n// - Firefox 14-29\n// - Internet Explorer 11\n// - iPad Safari 6-7.1\n// - iPhone Safari 7-7.1\n// - Safari 6-7\nif (typeof BrowserMutationObserver === \"function\") {\n requestFlush = makeRequestCallFromMutationObserver(flush);\n\n// MessageChannels are desirable because they give direct access to the HTML\n// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera\n// 11-12, and in web workers in many engines.\n// Although message channels yield to any queued rendering and IO tasks, they\n// would be better than imposing the 4ms delay of timers.\n// However, they do not work reliably in Internet Explorer or Safari.\n\n// Internet Explorer 10 is the only browser that has setImmediate but does\n// not have MutationObservers.\n// Although setImmediate yields to the browser's renderer, it would be\n// preferrable to falling back to setTimeout since it does not have\n// the minimum 4ms penalty.\n// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and\n// Desktop to a lesser extent) that renders both setImmediate and\n// MessageChannel useless for the purposes of ASAP.\n// https://github.com/kriskowal/q/issues/396\n\n// Timers are implemented universally.\n// We fall back to timers in workers in most engines, and in foreground\n// contexts in the following browsers.\n// However, note that even this simple case requires nuances to operate in a\n// broad spectrum of browsers.\n//\n// - Firefox 3-13\n// - Internet Explorer 6-9\n// - iPad Safari 4.3\n// - Lynx 2.8.7\n} else {\n requestFlush = makeRequestCallFromTimer(flush);\n}\n\n// `requestFlush` requests that the high priority event queue be flushed as\n// soon as possible.\n// This is useful to prevent an error thrown in a task from stalling the event\n// queue if the exception handled by Node.js’s\n// `process.on(\"uncaughtException\")` or by a domain.\nrawAsap.requestFlush = requestFlush;\n\n// To request a high priority event, we induce a mutation observer by toggling\n// the text of a text node between \"1\" and \"-1\".\nfunction makeRequestCallFromMutationObserver(callback) {\n var toggle = 1;\n var observer = new BrowserMutationObserver(callback);\n var node = document.createTextNode(\"\");\n observer.observe(node, {characterData: true});\n return function requestCall() {\n toggle = -toggle;\n node.data = toggle;\n };\n}\n\n// The message channel technique was discovered by Malte Ubl and was the\n// original foundation for this library.\n// http://www.nonblocking.io/2011/06/windownexttick.html\n\n// Safari 6.0.5 (at least) intermittently fails to create message ports on a\n// page's first load. Thankfully, this version of Safari supports\n// MutationObservers, so we don't need to fall back in that case.\n\n// function makeRequestCallFromMessageChannel(callback) {\n// var channel = new MessageChannel();\n// channel.port1.onmessage = callback;\n// return function requestCall() {\n// channel.port2.postMessage(0);\n// };\n// }\n\n// For reasons explained above, we are also unable to use `setImmediate`\n// under any circumstances.\n// Even if we were, there is another bug in Internet Explorer 10.\n// It is not sufficient to assign `setImmediate` to `requestFlush` because\n// `setImmediate` must be called *by name* and therefore must be wrapped in a\n// closure.\n// Never forget.\n\n// function makeRequestCallFromSetImmediate(callback) {\n// return function requestCall() {\n// setImmediate(callback);\n// };\n// }\n\n// Safari 6.0 has a problem where timers will get lost while the user is\n// scrolling. This problem does not impact ASAP because Safari 6.0 supports\n// mutation observers, so that implementation is used instead.\n// However, if we ever elect to use timers in Safari, the prevalent work-around\n// is to add a scroll event listener that calls for a flush.\n\n// `setTimeout` does not call the passed callback if the delay is less than\n// approximately 7 in web workers in Firefox 8 through 18, and sometimes not\n// even then.\n\nfunction makeRequestCallFromTimer(callback) {\n return function requestCall() {\n // We dispatch a timeout with a specified delay of 0 for engines that\n // can reliably accommodate that request. This will usually be snapped\n // to a 4 milisecond delay, but once we're flushing, there's no delay\n // between events.\n var timeoutHandle = setTimeout(handleTimer, 0);\n // However, since this timer gets frequently dropped in Firefox\n // workers, we enlist an interval handle that will try to fire\n // an event 20 times per second until it succeeds.\n var intervalHandle = setInterval(handleTimer, 50);\n\n function handleTimer() {\n // Whichever timer succeeds will cancel both timers and\n // execute the callback.\n clearTimeout(timeoutHandle);\n clearInterval(intervalHandle);\n callback();\n }\n };\n}\n\n// This is for `asap.js` only.\n// Its name will be periodically randomized to break any code that depends on\n// its existence.\nrawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;\n\n// ASAP was originally a nextTick shim included in Q. This was factored out\n// into this ASAP package. It was later adapted to RSVP which made further\n// amendments. These decisions, particularly to marginalize MessageChannel and\n// to capture the MutationObserver implementation in a closure, were integrated\n// back into ASAP proper.\n// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/asap/browser-raw.js\n ** module id = 6\n ** module chunks = 0\n **/","'use strict';\n\nvar extend = require('./extend');\n\nmodule.exports = function(parent, methods) {\n if (typeof parent !== 'function') {\n methods = parent;\n parent = Object;\n }\n\n var klass = function() {\n if (!this.initialize) return this;\n return this.initialize.apply(this, arguments) || this;\n };\n\n var bridge = function() {};\n bridge.prototype = parent.prototype;\n\n klass.prototype = new bridge();\n extend(klass.prototype, methods);\n\n return klass;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/class.js\n ** module id = 7\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = function(dest, source, overwrite) {\n if (!source) return dest;\n for (var key in source) {\n if (!source.hasOwnProperty(key)) continue;\n if (dest.hasOwnProperty(key) && overwrite === false) continue;\n if (dest[key] !== source[key])\n dest[key] = source[key];\n }\n return dest;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/extend.js\n ** module id = 8\n ** module chunks = 0\n **/","'use strict';\n\nvar asap = require('asap');\n\nvar PENDING = 0,\n FULFILLED = 1,\n REJECTED = 2;\n\nvar RETURN = function(x) { return x },\n THROW = function(x) { throw x };\n\nvar Promise = function(task) {\n this._state = PENDING;\n this._onFulfilled = [];\n this._onRejected = [];\n\n if (typeof task !== 'function') return;\n var self = this;\n\n task(function(value) { fulfill(self, value) },\n function(reason) { reject(self, reason) });\n};\n\nPromise.prototype.then = function(onFulfilled, onRejected) {\n var next = new Promise();\n registerOnFulfilled(this, onFulfilled, next);\n registerOnRejected(this, onRejected, next);\n return next;\n};\n\nPromise.prototype.catch = function(onRejected) {\n return this.then(null, onRejected);\n};\n\nvar registerOnFulfilled = function(promise, onFulfilled, next) {\n if (typeof onFulfilled !== 'function') onFulfilled = RETURN;\n var handler = function(value) { invoke(onFulfilled, value, next) };\n\n if (promise._state === PENDING) {\n promise._onFulfilled.push(handler);\n } else if (promise._state === FULFILLED) {\n handler(promise._value);\n }\n};\n\nvar registerOnRejected = function(promise, onRejected, next) {\n if (typeof onRejected !== 'function') onRejected = THROW;\n var handler = function(reason) { invoke(onRejected, reason, next) };\n\n if (promise._state === PENDING) {\n promise._onRejected.push(handler);\n } else if (promise._state === REJECTED) {\n handler(promise._reason);\n }\n};\n\nvar invoke = function(fn, value, next) {\n asap(function() { _invoke(fn, value, next) });\n};\n\nvar _invoke = function(fn, value, next) {\n var outcome;\n\n try {\n outcome = fn(value);\n } catch (error) {\n return reject(next, error);\n }\n\n if (outcome === next) {\n reject(next, new TypeError('Recursive promise chain detected'));\n } else {\n fulfill(next, outcome);\n }\n};\n\nvar fulfill = function(promise, value) {\n var called = false, type, then;\n\n try {\n type = typeof value;\n then = value !== null && (type === 'function' || type === 'object') && value.then;\n\n if (typeof then !== 'function') return _fulfill(promise, value);\n\n then.call(value, function(v) {\n if (!(called ^ (called = true))) return;\n fulfill(promise, v);\n }, function(r) {\n if (!(called ^ (called = true))) return;\n reject(promise, r);\n });\n } catch (error) {\n if (!(called ^ (called = true))) return;\n reject(promise, error);\n }\n};\n\nvar _fulfill = function(promise, value) {\n if (promise._state !== PENDING) return;\n\n promise._state = FULFILLED;\n promise._value = value;\n promise._onRejected = [];\n\n var onFulfilled = promise._onFulfilled, fn;\n while (fn = onFulfilled.shift()) fn(value);\n};\n\nvar reject = function(promise, reason) {\n if (promise._state !== PENDING) return;\n\n promise._state = REJECTED;\n promise._reason = reason;\n promise._onFulfilled = [];\n\n var onRejected = promise._onRejected, fn;\n while (fn = onRejected.shift()) fn(reason);\n};\n\nPromise.resolve = Promise.accept = Promise.fulfill = function(value) {\n return new Promise(function(resolve, reject) { resolve(value) });\n};\n\nPromise.reject = function(reason) {\n return new Promise(function(resolve, reject) { reject(reason) });\n};\n\nPromise.all = function(promises) {\n return new Promise(function(resolve, reject) {\n var list = [], n = promises.length, i;\n\n if (n === 0) return resolve(list);\n\n for (i = 0; i < n; i++) (function(promise, i) {\n Promise.resolve(promise).then(function(value) {\n list[i] = value;\n if (--n === 0) resolve(list);\n }, reject);\n })(promises[i], i);\n });\n};\n\nPromise.race = function(promises) {\n return new Promise(function(resolve, reject) {\n for (var i = 0, n = promises.length; i < n; i++)\n Promise.resolve(promises[i]).then(resolve, reject);\n });\n};\n\nPromise.deferred = Promise.pending = function() {\n var tuple = {};\n\n tuple.promise = new Promise(function(resolve, reject) {\n tuple.fulfill = tuple.resolve = resolve;\n tuple.reject = reject;\n });\n return tuple;\n};\n\nmodule.exports = Promise;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/promise.js\n ** module id = 9\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = {\n isURI: function(uri) {\n return uri && uri.protocol && uri.host && uri.path;\n },\n\n isSameOrigin: function(uri) {\n return uri.protocol === location.protocol &&\n uri.hostname === location.hostname &&\n uri.port === location.port;\n },\n\n parse: function(url) {\n if (typeof url !== 'string') return url;\n var uri = {}, parts, query, pairs, i, n, data;\n\n var consume = function(name, pattern) {\n url = url.replace(pattern, function(match) {\n uri[name] = match;\n return '';\n });\n uri[name] = uri[name] || '';\n };\n\n consume('protocol', /^[a-z]+\\:/i);\n consume('host', /^\\/\\/[^\\/\\?#]+/);\n\n if (!/^\\//.test(url) && !uri.host)\n url = location.pathname.replace(/[^\\/]*$/, '') + url;\n\n consume('pathname', /^[^\\?#]*/);\n consume('search', /^\\?[^#]*/);\n consume('hash', /^#.*/);\n\n uri.protocol = uri.protocol || location.protocol;\n\n if (uri.host) {\n uri.host = uri.host.substr(2);\n parts = uri.host.split(':');\n uri.hostname = parts[0];\n uri.port = parts[1] || '';\n } else {\n uri.host = location.host;\n uri.hostname = location.hostname;\n uri.port = location.port;\n }\n\n uri.pathname = uri.pathname || '/';\n uri.path = uri.pathname + uri.search;\n\n query = uri.search.replace(/^\\?/, '');\n pairs = query ? query.split('&') : [];\n data = {};\n\n for (i = 0, n = pairs.length; i < n; i++) {\n parts = pairs[i].split('=');\n data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');\n }\n\n uri.query = data;\n\n uri.href = this.stringify(uri);\n return uri;\n },\n\n stringify: function(uri) {\n var string = uri.protocol + '//' + uri.hostname;\n if (uri.port) string += ':' + uri.port;\n string += uri.pathname + this.queryString(uri.query) + (uri.hash || '');\n return string;\n },\n\n queryString: function(query) {\n var pairs = [];\n for (var key in query) {\n if (!query.hasOwnProperty(key)) continue;\n pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(query[key]));\n }\n if (pairs.length === 0) return '';\n return '?' + pairs.join('&');\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/uri.js\n ** module id = 10\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = {\n commonElement: function(lista, listb) {\n for (var i = 0, n = lista.length; i < n; i++) {\n if (this.indexOf(listb, lista[i]) !== -1)\n return lista[i];\n }\n return null;\n },\n\n indexOf: function(list, needle) {\n if (list.indexOf) return list.indexOf(needle);\n\n for (var i = 0, n = list.length; i < n; i++) {\n if (list[i] === needle) return i;\n }\n return -1;\n },\n\n map: function(object, callback, context) {\n if (object.map) return object.map(callback, context);\n var result = [];\n\n if (object instanceof Array) {\n for (var i = 0, n = object.length; i < n; i++) {\n result.push(callback.call(context || null, object[i], i));\n }\n } else {\n for (var key in object) {\n if (!object.hasOwnProperty(key)) continue;\n result.push(callback.call(context || null, key, object[key]));\n }\n }\n return result;\n },\n\n filter: function(array, callback, context) {\n if (array.filter) return array.filter(callback, context);\n var result = [];\n for (var i = 0, n = array.length; i < n; i++) {\n if (callback.call(context || null, array[i], i))\n result.push(array[i]);\n }\n return result;\n },\n\n asyncEach: function(list, iterator, callback, context) {\n var n = list.length,\n i = -1,\n calls = 0,\n looping = false;\n\n var iterate = function() {\n calls -= 1;\n i += 1;\n if (i === n) return callback && callback.call(context);\n iterator(list[i], resume);\n };\n\n var loop = function() {\n if (looping) return;\n looping = true;\n while (calls > 0) iterate();\n looping = false;\n };\n\n var resume = function() {\n calls += 1;\n loop();\n };\n resume();\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/array.js\n ** module id = 11\n ** module chunks = 0\n **/","'use strict';\n\nvar Event = {\n _registry: [],\n\n on: function(element, eventName, callback, context) {\n var wrapped = function() { callback.call(context) };\n\n if (element.addEventListener)\n element.addEventListener(eventName, wrapped, false);\n else\n element.attachEvent('on' + eventName, wrapped);\n\n this._registry.push({\n _element: element,\n _type: eventName,\n _callback: callback,\n _context: context,\n _handler: wrapped\n });\n },\n\n detach: function(element, eventName, callback, context) {\n var i = this._registry.length, register;\n while (i--) {\n register = this._registry[i];\n\n if ((element && element !== register._element) ||\n (eventName && eventName !== register._type) ||\n (callback && callback !== register._callback) ||\n (context && context !== register._context))\n continue;\n\n if (register._element.removeEventListener)\n register._element.removeEventListener(register._type, register._handler, false);\n else\n register._element.detachEvent('on' + register._type, register._handler);\n\n this._registry.splice(i,1);\n register = null;\n }\n }\n};\n\nif (global.onunload !== undefined)\n Event.on(global, 'unload', Event.detach, Event);\n\nmodule.exports = {\n Event: Event\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/browser/event.js\n ** module id = 12\n ** module chunks = 0\n **/","'use strict';\n\nvar array = require('./array');\n\nmodule.exports = function(options, validKeys) {\n for (var key in options) {\n if (array.indexOf(validKeys, key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/validate_options.js\n ** module id = 13\n ** module chunks = 0\n **/","'use strict';\n\nvar Promise = require('../util/promise');\n\nmodule.exports = {\n then: function(callback, errback) {\n var self = this;\n if (!this._promise)\n this._promise = new Promise(function(resolve, reject) {\n self._resolve = resolve;\n self._reject = reject;\n });\n\n if (arguments.length === 0)\n return this._promise;\n else\n return this._promise.then(callback, errback);\n },\n\n callback: function(callback, context) {\n return this.then(function(value) { callback.call(context, value) });\n },\n\n errback: function(callback, context) {\n return this.then(null, function(reason) { callback.call(context, reason) });\n },\n\n timeout: function(seconds, message) {\n this.then();\n var self = this;\n this._timer = global.setTimeout(function() {\n self._reject(message);\n }, seconds * 1000);\n },\n\n setDeferredStatus: function(status, value) {\n if (this._timer) global.clearTimeout(this._timer);\n\n this.then();\n\n if (status === 'succeeded')\n this._resolve(value);\n else if (status === 'failed')\n this._reject(value);\n else\n delete this._promise;\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/mixins/deferrable.js\n ** module id = 14\n ** module chunks = 0\n **/","'use strict';\n\nvar extend = require('../util/extend'),\n EventEmitter = require('../util/event_emitter');\n\nvar Publisher = {\n countListeners: function(eventType) {\n return this.listeners(eventType).length;\n },\n\n bind: function(eventType, listener, context) {\n var slice = Array.prototype.slice,\n handler = function() { listener.apply(context, slice.call(arguments)) };\n\n this._listeners = this._listeners || [];\n this._listeners.push([eventType, listener, context, handler]);\n return this.on(eventType, handler);\n },\n\n unbind: function(eventType, listener, context) {\n this._listeners = this._listeners || [];\n var n = this._listeners.length, tuple;\n\n while (n--) {\n tuple = this._listeners[n];\n if (tuple[0] !== eventType) continue;\n if (listener && (tuple[1] !== listener || tuple[2] !== context)) continue;\n this._listeners.splice(n, 1);\n this.removeListener(eventType, tuple[3]);\n }\n }\n};\n\nextend(Publisher, EventEmitter.prototype);\nPublisher.trigger = Publisher.emit;\n\nmodule.exports = Publisher;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/mixins/publisher.js\n ** module id = 15\n ** module chunks = 0\n **/","/*\nCopyright Joyent, Inc. and other Node contributors. All rights reserved.\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\nvar isArray = typeof Array.isArray === 'function'\n ? Array.isArray\n : function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]'\n }\n;\nfunction indexOf (xs, x) {\n if (xs.indexOf) return xs.indexOf(x);\n for (var i = 0; i < xs.length; i++) {\n if (x === xs[i]) return i;\n }\n return -1;\n}\n\nfunction EventEmitter() {}\nmodule.exports = EventEmitter;\n\nEventEmitter.prototype.emit = function(type) {\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events || !this._events.error ||\n (isArray(this._events.error) && !this._events.error.length))\n {\n if (arguments[1] instanceof Error) {\n throw arguments[1]; // Unhandled 'error' event\n } else {\n throw new Error(\"Uncaught, unspecified 'error' event.\");\n }\n return false;\n }\n }\n\n if (!this._events) return false;\n var handler = this._events[type];\n if (!handler) return false;\n\n if (typeof handler == 'function') {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n var args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n return true;\n\n } else if (isArray(handler)) {\n var args = Array.prototype.slice.call(arguments, 1);\n\n var listeners = handler.slice();\n for (var i = 0, l = listeners.length; i < l; i++) {\n listeners[i].apply(this, args);\n }\n return true;\n\n } else {\n return false;\n }\n};\n\n// EventEmitter is defined in src/node_events.cc\n// EventEmitter.prototype.emit() is also defined there.\nEventEmitter.prototype.addListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('addListener only takes instances of Function');\n }\n\n if (!this._events) this._events = {};\n\n // To avoid recursion in the case that type == \"newListeners\"! Before\n // adding it to the listeners, first emit \"newListeners\".\n this.emit('newListener', type, listener);\n\n if (!this._events[type]) {\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n } else if (isArray(this._events[type])) {\n // If we've already got an array, just append.\n this._events[type].push(listener);\n } else {\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n var self = this;\n self.on(type, function g() {\n self.removeListener(type, g);\n listener.apply(this, arguments);\n });\n\n return this;\n};\n\nEventEmitter.prototype.removeListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('removeListener only takes instances of Function');\n }\n\n // does not use listeners(), so no side effect of creating _events[type]\n if (!this._events || !this._events[type]) return this;\n\n var list = this._events[type];\n\n if (isArray(list)) {\n var i = indexOf(list, listener);\n if (i < 0) return this;\n list.splice(i, 1);\n if (list.length == 0)\n delete this._events[type];\n } else if (this._events[type] === listener) {\n delete this._events[type];\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n if (arguments.length === 0) {\n this._events = {};\n return this;\n }\n\n // does not use listeners(), so no side effect of creating _events[type]\n if (type && this._events && this._events[type]) this._events[type] = null;\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n if (!this._events) this._events = {};\n if (!this._events[type]) this._events[type] = [];\n if (!isArray(this._events[type])) {\n this._events[type] = [this._events[type]];\n }\n return this._events[type];\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/event_emitter.js\n ** module id = 16\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n extend = require('../util/extend'),\n Publisher = require('../mixins/publisher'),\n Grammar = require('./grammar');\n\nvar Channel = Class({\n initialize: function(name) {\n this.id = this.name = name;\n },\n\n push: function(message) {\n this.trigger('message', message);\n },\n\n isUnused: function() {\n return this.countListeners('message') === 0;\n }\n});\n\nextend(Channel.prototype, Publisher);\n\nextend(Channel, {\n HANDSHAKE: '/meta/handshake',\n CONNECT: '/meta/connect',\n SUBSCRIBE: '/meta/subscribe',\n UNSUBSCRIBE: '/meta/unsubscribe',\n DISCONNECT: '/meta/disconnect',\n\n META: 'meta',\n SERVICE: 'service',\n\n expand: function(name) {\n var segments = this.parse(name),\n channels = ['/**', name];\n\n var copy = segments.slice();\n copy[copy.length - 1] = '*';\n channels.push(this.unparse(copy));\n\n for (var i = 1, n = segments.length; i < n; i++) {\n copy = segments.slice(0, i);\n copy.push('**');\n channels.push(this.unparse(copy));\n }\n\n return channels;\n },\n\n isValid: function(name) {\n return Grammar.CHANNEL_NAME.test(name) ||\n Grammar.CHANNEL_PATTERN.test(name);\n },\n\n parse: function(name) {\n if (!this.isValid(name)) return null;\n return name.split('/').slice(1);\n },\n\n unparse: function(segments) {\n return '/' + segments.join('/');\n },\n\n isMeta: function(name) {\n var segments = this.parse(name);\n return segments ? (segments[0] === this.META) : null;\n },\n\n isService: function(name) {\n var segments = this.parse(name);\n return segments ? (segments[0] === this.SERVICE) : null;\n },\n\n isSubscribable: function(name) {\n if (!this.isValid(name)) return null;\n return !this.isMeta(name) && !this.isService(name);\n },\n\n Set: Class({\n initialize: function() {\n this._channels = {};\n },\n\n getKeys: function() {\n var keys = [];\n for (var key in this._channels) keys.push(key);\n return keys;\n },\n\n remove: function(name) {\n delete this._channels[name];\n },\n\n hasSubscription: function(name) {\n return this._channels.hasOwnProperty(name);\n },\n\n subscribe: function(names, subscription) {\n var name;\n for (var i = 0, n = names.length; i < n; i++) {\n name = names[i];\n var channel = this._channels[name] = this._channels[name] || new Channel(name);\n channel.bind('message', subscription);\n }\n },\n\n unsubscribe: function(name, subscription) {\n var channel = this._channels[name];\n if (!channel) return false;\n channel.unbind('message', subscription);\n\n if (channel.isUnused()) {\n this.remove(name);\n return true;\n } else {\n return false;\n }\n },\n\n distributeMessage: function(message) {\n var channels = Channel.expand(message.channel);\n\n for (var i = 0, n = channels.length; i < n; i++) {\n var channel = this._channels[channels[i]];\n if (channel) channel.trigger('message', message);\n }\n }\n })\n});\n\nmodule.exports = Channel;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/channel.js\n ** module id = 17\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = {\n CHANNEL_NAME: /^\\/(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)))+(\\/(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)))+)*$/,\n CHANNEL_PATTERN: /^(\\/(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)))+)*\\/\\*{1,2}$/,\n 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])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)| |\\/|\\*|\\.))*)$/,\n VERSION: /^([0-9])+(\\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\\-|\\_))*)*$/\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/grammar.js\n ** module id = 18\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n cookies = require('../util/cookies'),\n extend = require('../util/extend'),\n Logging = require('../mixins/logging'),\n Publisher = require('../mixins/publisher'),\n Transport = require('../transport'),\n Scheduler = require('./scheduler');\n\nvar Dispatcher = Class({ className: 'Dispatcher',\n MAX_REQUEST_SIZE: 2048,\n DEFAULT_RETRY: 5,\n\n UP: 1,\n DOWN: 2,\n\n initialize: function(client, endpoint, options) {\n this._client = client;\n this.endpoint = URI.parse(endpoint);\n this._alternates = options.endpoints || {};\n\n this.cookies = cookies.CookieJar && new cookies.CookieJar();\n this._disabled = [];\n this._envelopes = {};\n this.headers = {};\n this.retry = options.retry || this.DEFAULT_RETRY;\n this._scheduler = options.scheduler || Scheduler;\n this._state = 0;\n this.transports = {};\n this.wsExtensions = [];\n\n this.proxy = options.proxy || {};\n if (typeof this._proxy === 'string') this._proxy = {origin: this._proxy};\n\n var exts = options.websocketExtensions;\n if (exts) {\n exts = [].concat(exts);\n for (var i = 0, n = exts.length; i < n; i++)\n this.addWebsocketExtension(exts[i]);\n }\n\n this.tls = options.tls || {};\n this.tls.ca = this.tls.ca || options.ca;\n\n for (var type in this._alternates)\n this._alternates[type] = URI.parse(this._alternates[type]);\n\n this.maxRequestSize = this.MAX_REQUEST_SIZE;\n },\n\n endpointFor: function(connectionType) {\n return this._alternates[connectionType] || this.endpoint;\n },\n\n addWebsocketExtension: function(extension) {\n this.wsExtensions.push(extension);\n },\n\n disable: function(feature) {\n this._disabled.push(feature);\n },\n\n setHeader: function(name, value) {\n this.headers[name] = value;\n },\n\n close: function() {\n var transport = this._transport;\n delete this._transport;\n if (transport) transport.close();\n },\n\n getConnectionTypes: function() {\n return Transport.getConnectionTypes();\n },\n\n selectTransport: function(transportTypes) {\n Transport.get(this, transportTypes, this._disabled, function(transport) {\n this.debug('Selected ? transport for ?', transport.connectionType, URI.stringify(transport.endpoint));\n\n if (transport === this._transport) return;\n if (this._transport) this._transport.close();\n\n this._transport = transport;\n this.connectionType = transport.connectionType;\n }, this);\n },\n\n sendMessage: function(message, timeout, options) {\n options = options || {};\n\n var id = message.id,\n attempts = options.attempts,\n deadline = options.deadline && new Date().getTime() + (options.deadline * 1000),\n envelope = this._envelopes[id],\n scheduler;\n\n if (!envelope) {\n scheduler = new this._scheduler(message, {timeout: timeout, interval: this.retry, attempts: attempts, deadline: deadline});\n envelope = this._envelopes[id] = {message: message, scheduler: scheduler};\n }\n\n this._sendEnvelope(envelope);\n },\n\n _sendEnvelope: function(envelope) {\n if (!this._transport) return;\n if (envelope.request || envelope.timer) return;\n\n var message = envelope.message,\n scheduler = envelope.scheduler,\n self = this;\n\n if (!scheduler.isDeliverable()) {\n scheduler.abort();\n delete this._envelopes[message.id];\n return;\n }\n\n envelope.timer = global.setTimeout(function() {\n self.handleError(message);\n }, scheduler.getTimeout() * 1000);\n\n scheduler.send();\n envelope.request = this._transport.sendMessage(message);\n },\n\n handleResponse: function(reply) {\n var envelope = this._envelopes[reply.id];\n\n if (reply.successful !== undefined && envelope) {\n envelope.scheduler.succeed();\n delete this._envelopes[reply.id];\n global.clearTimeout(envelope.timer);\n }\n\n this.trigger('message', reply);\n\n if (this._state === this.UP) return;\n this._state = this.UP;\n this._client.trigger('transport:up');\n },\n\n handleError: function(message, immediate) {\n var envelope = this._envelopes[message.id],\n request = envelope && envelope.request,\n self = this;\n\n if (!request) return;\n\n request.then(function(req) {\n if (req && req.abort) req.abort();\n });\n\n var scheduler = envelope.scheduler;\n scheduler.fail();\n\n global.clearTimeout(envelope.timer);\n envelope.request = envelope.timer = null;\n\n if (immediate) {\n this._sendEnvelope(envelope);\n } else {\n envelope.timer = global.setTimeout(function() {\n envelope.timer = null;\n self._sendEnvelope(envelope);\n }, scheduler.getInterval() * 1000);\n }\n\n if (this._state === this.DOWN) return;\n this._state = this.DOWN;\n this._client.trigger('transport:down');\n }\n});\n\nDispatcher.create = function(client, endpoint, options) {\n return new Dispatcher(client, endpoint, options);\n};\n\nextend(Dispatcher.prototype, Publisher);\nextend(Dispatcher.prototype, Logging);\n\nmodule.exports = Dispatcher;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/dispatcher.js\n ** module id = 19\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = {};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/cookies/browser_cookies.js\n ** module id = 20\n ** module chunks = 0\n **/","'use strict';\n\nvar Transport = require('./transport');\n\nTransport.register('websocket', require('./web_socket'));\nTransport.register('eventsource', require('./event_source'));\nTransport.register('long-polling', require('./xhr'));\nTransport.register('cross-origin-long-polling', require('./cors'));\nTransport.register('callback-polling', require('./jsonp'));\n\nmodule.exports = Transport;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/transport/browser_transports.js\n ** module id = 21\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n Cookie = require('../util/cookies').Cookie,\n Promise = require('../util/promise'),\n URI = require('../util/uri'),\n array = require('../util/array'),\n extend = require('../util/extend'),\n Logging = require('../mixins/logging'),\n Timeouts = require('../mixins/timeouts'),\n Channel = require('../protocol/channel');\n\nvar Transport = extend(Class({ className: 'Transport',\n DEFAULT_PORTS: {'http:': 80, 'https:': 443, 'ws:': 80, 'wss:': 443},\n SECURE_PROTOCOLS: ['https:', 'wss:'],\n MAX_DELAY: 0,\n\n batching: true,\n\n initialize: function(dispatcher, endpoint) {\n this._dispatcher = dispatcher;\n this.endpoint = endpoint;\n this._outbox = [];\n this._proxy = extend({}, this._dispatcher.proxy);\n\n if (!this._proxy.origin && typeof process !== 'undefined') {\n this._proxy.origin = array.indexOf(this.SECURE_PROTOCOLS, this.endpoint.protocol) >= 0\n ? (process.env.HTTPS_PROXY || process.env.https_proxy)\n : (process.env.HTTP_PROXY || process.env.http_proxy);\n }\n },\n\n close: function() {},\n\n encode: function(messages) {\n return '';\n },\n\n sendMessage: function(message) {\n this.debug('Client ? sending message to ?: ?',\n this._dispatcher.clientId, URI.stringify(this.endpoint), message);\n\n if (!this.batching) return Promise.resolve(this.request([message]));\n\n this._outbox.push(message);\n this._flushLargeBatch();\n\n if (message.channel === Channel.HANDSHAKE)\n return this._publish(0.01);\n\n if (message.channel === Channel.CONNECT)\n this._connectMessage = message;\n\n return this._publish(this.MAX_DELAY);\n },\n\n _makePromise: function() {\n var self = this;\n\n this._requestPromise = this._requestPromise || new Promise(function(resolve) {\n self._resolvePromise = resolve;\n });\n },\n\n _publish: function(delay) {\n this._makePromise();\n\n this.addTimeout('publish', delay, function() {\n this._flush();\n delete this._requestPromise;\n }, this);\n\n return this._requestPromise;\n },\n\n _flush: function() {\n this.removeTimeout('publish');\n\n if (this._outbox.length > 1 && this._connectMessage)\n this._connectMessage.advice = {timeout: 0};\n\n this._resolvePromise(this.request(this._outbox));\n\n this._connectMessage = null;\n this._outbox = [];\n },\n\n _flushLargeBatch: function() {\n var string = this.encode(this._outbox);\n if (string.length < this._dispatcher.maxRequestSize) return;\n var last = this._outbox.pop();\n\n this._makePromise();\n this._flush();\n\n if (last) this._outbox.push(last);\n },\n\n _receive: function(replies) {\n if (!replies) return;\n replies = [].concat(replies);\n\n this.debug('Client ? received from ? via ?: ?',\n this._dispatcher.clientId, URI.stringify(this.endpoint), this.connectionType, replies);\n\n for (var i = 0, n = replies.length; i < n; i++)\n this._dispatcher.handleResponse(replies[i]);\n },\n\n _handleError: function(messages, immediate) {\n messages = [].concat(messages);\n\n this.debug('Client ? failed to send to ? via ?: ?',\n this._dispatcher.clientId, URI.stringify(this.endpoint), this.connectionType, messages);\n\n for (var i = 0, n = messages.length; i < n; i++)\n this._dispatcher.handleError(messages[i]);\n },\n\n _getCookies: function() {\n var cookies = this._dispatcher.cookies,\n url = URI.stringify(this.endpoint);\n\n if (!cookies) return '';\n\n return array.map(cookies.getCookiesSync(url), function(cookie) {\n return cookie.cookieString();\n }).join('; ');\n },\n\n _storeCookies: function(setCookie) {\n var cookies = this._dispatcher.cookies,\n url = URI.stringify(this.endpoint),\n cookie;\n\n if (!setCookie || !cookies) return;\n setCookie = [].concat(setCookie);\n\n for (var i = 0, n = setCookie.length; i < n; i++) {\n cookie = Cookie.parse(setCookie[i]);\n cookies.setCookieSync(cookie, url);\n }\n }\n\n}), {\n get: function(dispatcher, allowed, disabled, callback, context) {\n var endpoint = dispatcher.endpoint;\n\n array.asyncEach(this._transports, function(pair, resume) {\n var connType = pair[0], klass = pair[1],\n connEndpoint = dispatcher.endpointFor(connType);\n\n if (array.indexOf(disabled, connType) >= 0)\n return resume();\n\n if (array.indexOf(allowed, connType) < 0) {\n klass.isUsable(dispatcher, connEndpoint, function() {});\n return resume();\n }\n\n klass.isUsable(dispatcher, connEndpoint, function(isUsable) {\n if (!isUsable) return resume();\n var transport = klass.hasOwnProperty('create') ? klass.create(dispatcher, connEndpoint) : new klass(dispatcher, connEndpoint);\n callback.call(context, transport);\n });\n }, function() {\n throw new Error('Could not find a usable connection type for ' + URI.stringify(endpoint));\n });\n },\n\n register: function(type, klass) {\n this._transports.push([type, klass]);\n klass.prototype.connectionType = type;\n },\n\n getConnectionTypes: function() {\n return array.map(this._transports, function(t) { return t[0] });\n },\n\n _transports: []\n});\n\nextend(Transport.prototype, Logging);\nextend(Transport.prototype, Timeouts);\n\nmodule.exports = Transport;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/transport/transport.js\n ** module id = 22\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = {\n addTimeout: function(name, delay, callback, context) {\n this._timeouts = this._timeouts || {};\n if (this._timeouts.hasOwnProperty(name)) return;\n var self = this;\n this._timeouts[name] = global.setTimeout(function() {\n delete self._timeouts[name];\n callback.call(context);\n }, 1000 * delay);\n },\n\n removeTimeout: function(name) {\n this._timeouts = this._timeouts || {};\n var timeout = this._timeouts[name];\n if (!timeout) return;\n global.clearTimeout(timeout);\n delete this._timeouts[name];\n },\n\n removeAllTimeouts: function() {\n this._timeouts = this._timeouts || {};\n for (var name in this._timeouts) this.removeTimeout(name);\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/mixins/timeouts.js\n ** module id = 23\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n Promise = require('../util/promise'),\n Set = require('../util/set'),\n URI = require('../util/uri'),\n browser = require('../util/browser'),\n copyObject = require('../util/copy_object'),\n extend = require('../util/extend'),\n toJSON = require('../util/to_json'),\n ws = require('../util/websocket'),\n Deferrable = require('../mixins/deferrable'),\n Transport = require('./transport');\n\nvar WebSocket = extend(Class(Transport, {\n UNCONNECTED: 1,\n CONNECTING: 2,\n CONNECTED: 3,\n\n batching: false,\n\n isUsable: function(callback, context) {\n this.callback(function() { callback.call(context, true) });\n this.errback(function() { callback.call(context, false) });\n this.connect();\n },\n\n request: function(messages) {\n this._pending = this._pending || new Set();\n for (var i = 0, n = messages.length; i < n; i++) this._pending.add(messages[i]);\n\n var self = this;\n\n var promise = new Promise(function(resolve, reject) {\n self.callback(function(socket) {\n if (!socket || socket.readyState !== 1) return;\n socket.send(toJSON(messages));\n resolve(socket);\n });\n\n self.connect();\n });\n\n return {\n abort: function() { promise.then(function(ws) { ws.close() }) }\n };\n },\n\n connect: function() {\n if (WebSocket._unloaded) return;\n\n this._state = this._state || this.UNCONNECTED;\n if (this._state !== this.UNCONNECTED) return;\n this._state = this.CONNECTING;\n\n var socket = this._createSocket();\n if (!socket) return this.setDeferredStatus('failed');\n\n var self = this;\n\n socket.onopen = function() {\n if (socket.headers) self._storeCookies(socket.headers['set-cookie']);\n self._socket = socket;\n self._state = self.CONNECTED;\n self._everConnected = true;\n self._ping();\n self.setDeferredStatus('succeeded', socket);\n };\n\n var closed = false;\n socket.onclose = socket.onerror = function() {\n if (closed) return;\n closed = true;\n\n var wasConnected = (self._state === self.CONNECTED);\n socket.onopen = socket.onclose = socket.onerror = socket.onmessage = null;\n\n delete self._socket;\n self._state = self.UNCONNECTED;\n self.removeTimeout('ping');\n\n var pending = self._pending ? self._pending.toArray() : [];\n delete self._pending;\n\n if (wasConnected || self._everConnected) {\n self.setDeferredStatus('unknown');\n self._handleError(pending, wasConnected);\n } else {\n self.setDeferredStatus('failed');\n }\n };\n\n socket.onmessage = function(event) {\n var replies;\n try { replies = JSON.parse(event.data) } catch (error) {}\n\n if (!replies) return;\n\n replies = [].concat(replies);\n\n for (var i = 0, n = replies.length; i < n; i++) {\n if (replies[i].successful === undefined) continue;\n self._pending.remove(replies[i]);\n }\n self._receive(replies);\n };\n },\n\n close: function() {\n if (!this._socket) return;\n this._socket.close();\n },\n\n _createSocket: function() {\n var url = WebSocket.getSocketUrl(this.endpoint),\n headers = this._dispatcher.headers,\n extensions = this._dispatcher.wsExtensions,\n cookie = this._getCookies(),\n tls = this._dispatcher.tls,\n options = {extensions: extensions, headers: headers, proxy: this._proxy, tls: tls};\n\n if (cookie !== '') options.headers['Cookie'] = cookie;\n\n return ws.create(url, [], options);\n },\n\n _ping: function() {\n if (!this._socket || this._socket.readyState !== 1) return;\n this._socket.send('[]');\n this.addTimeout('ping', this._dispatcher.timeout / 2, this._ping, this);\n }\n\n}), {\n PROTOCOLS: {\n 'http:': 'ws:',\n 'https:': 'wss:'\n },\n\n create: function(dispatcher, endpoint) {\n var sockets = dispatcher.transports.websocket = dispatcher.transports.websocket || {};\n sockets[endpoint.href] = sockets[endpoint.href] || new this(dispatcher, endpoint);\n return sockets[endpoint.href];\n },\n\n getSocketUrl: function(endpoint) {\n endpoint = copyObject(endpoint);\n endpoint.protocol = this.PROTOCOLS[endpoint.protocol];\n return URI.stringify(endpoint);\n },\n\n isUsable: function(dispatcher, endpoint, callback, context) {\n this.create(dispatcher, endpoint).isUsable(callback, context);\n }\n});\n\nextend(WebSocket.prototype, Deferrable);\n\nif (browser.Event && global.onbeforeunload !== undefined)\n browser.Event.on(global, 'beforeunload', function() { WebSocket._unloaded = true });\n\nmodule.exports = WebSocket;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/transport/web_socket.js\n ** module id = 24\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('./class');\n\nmodule.exports = Class({\n initialize: function() {\n this._index = {};\n },\n\n add: function(item) {\n var key = (item.id !== undefined) ? item.id : item;\n if (this._index.hasOwnProperty(key)) return false;\n this._index[key] = item;\n return true;\n },\n\n forEach: function(block, context) {\n for (var key in this._index) {\n if (this._index.hasOwnProperty(key))\n block.call(context, this._index[key]);\n }\n },\n\n isEmpty: function() {\n for (var key in this._index) {\n if (this._index.hasOwnProperty(key)) return false;\n }\n return true;\n },\n\n member: function(item) {\n for (var key in this._index) {\n if (this._index[key] === item) return true;\n }\n return false;\n },\n\n remove: function(item) {\n var key = (item.id !== undefined) ? item.id : item;\n var removed = this._index[key];\n delete this._index[key];\n return removed;\n },\n\n toArray: function() {\n var array = [];\n this.forEach(function(item) { array.push(item) });\n return array;\n }\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/set.js\n ** module id = 25\n ** module chunks = 0\n **/","'use strict';\n\nvar copyObject = function(object) {\n var clone, i, key;\n if (object instanceof Array) {\n clone = [];\n i = object.length;\n while (i--) clone[i] = copyObject(object[i]);\n return clone;\n } else if (typeof object === 'object') {\n clone = (object === null) ? null : {};\n for (key in object) clone[key] = copyObject(object[key]);\n return clone;\n } else {\n return object;\n }\n};\n\nmodule.exports = copyObject;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/copy_object.js\n ** module id = 26\n ** module chunks = 0\n **/","'use strict';\n\nvar WS = global.MozWebSocket || global.WebSocket;\n\nmodule.exports = {\n create: function(url, protocols, options) {\n return new WS(url);\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/util/websocket/browser_websocket.js\n ** module id = 27\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n copyObject = require('../util/copy_object'),\n extend = require('../util/extend'),\n Deferrable = require('../mixins/deferrable'),\n Transport = require('./transport'),\n XHR = require('./xhr');\n\nvar EventSource = extend(Class(Transport, {\n initialize: function(dispatcher, endpoint) {\n Transport.prototype.initialize.call(this, dispatcher, endpoint);\n if (!global.EventSource) return this.setDeferredStatus('failed');\n\n this._xhr = new XHR(dispatcher, endpoint);\n\n endpoint = copyObject(endpoint);\n endpoint.pathname += '/' + dispatcher.clientId;\n\n var socket = new global.EventSource(URI.stringify(endpoint)),\n self = this;\n\n socket.onopen = function() {\n self._everConnected = true;\n self.setDeferredStatus('succeeded');\n };\n\n socket.onerror = function() {\n if (self._everConnected) {\n self._handleError([]);\n } else {\n self.setDeferredStatus('failed');\n socket.close();\n }\n };\n\n socket.onmessage = function(event) {\n var replies;\n try { replies = JSON.parse(event.data) } catch (error) {}\n\n if (replies)\n self._receive(replies);\n else\n self._handleError([]);\n };\n\n this._socket = socket;\n },\n\n close: function() {\n if (!this._socket) return;\n this._socket.onopen = this._socket.onerror = this._socket.onmessage = null;\n this._socket.close();\n delete this._socket;\n },\n\n isUsable: function(callback, context) {\n this.callback(function() { callback.call(context, true) });\n this.errback(function() { callback.call(context, false) });\n },\n\n encode: function(messages) {\n return this._xhr.encode(messages);\n },\n\n request: function(messages) {\n return this._xhr.request(messages);\n }\n\n}), {\n isUsable: function(dispatcher, endpoint, callback, context) {\n var id = dispatcher.clientId;\n if (!id) return callback.call(context, false);\n\n XHR.isUsable(dispatcher, endpoint, function(usable) {\n if (!usable) return callback.call(context, false);\n this.create(dispatcher, endpoint).isUsable(callback, context);\n }, this);\n },\n\n create: function(dispatcher, endpoint) {\n var sockets = dispatcher.transports.eventsource = dispatcher.transports.eventsource || {},\n id = dispatcher.clientId;\n\n var url = copyObject(endpoint);\n url.pathname += '/' + (id || '');\n url = URI.stringify(url);\n\n sockets[url] = sockets[url] || new this(dispatcher, endpoint);\n return sockets[url];\n }\n});\n\nextend(EventSource.prototype, Deferrable);\n\nmodule.exports = EventSource;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/transport/event_source.js\n ** module id = 28\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n browser = require('../util/browser'),\n extend = require('../util/extend'),\n toJSON = require('../util/to_json'),\n Transport = require('./transport');\n\nvar XHR = extend(Class(Transport, {\n encode: function(messages) {\n return toJSON(messages);\n },\n\n request: function(messages) {\n var href = this.endpoint.href,\n self = this,\n xhr;\n\n // Prefer XMLHttpRequest over ActiveXObject if they both exist\n if (global.XMLHttpRequest) {\n xhr = new XMLHttpRequest();\n } else if (global.ActiveXObject) {\n xhr = new ActiveXObject('Microsoft.XMLHTTP');\n } else {\n return this._handleError(messages);\n }\n\n xhr.open('POST', href, true);\n xhr.setRequestHeader('Content-Type', 'application/json');\n xhr.setRequestHeader('Pragma', 'no-cache');\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n\n var headers = this._dispatcher.headers;\n for (var key in headers) {\n if (!headers.hasOwnProperty(key)) continue;\n xhr.setRequestHeader(key, headers[key]);\n }\n\n var abort = function() { xhr.abort() };\n if (global.onbeforeunload !== undefined)\n browser.Event.on(global, 'beforeunload', abort);\n\n xhr.onreadystatechange = function() {\n if (!xhr || xhr.readyState !== 4) return;\n\n var replies = null,\n status = xhr.status,\n text = xhr.responseText,\n successful = (status >= 200 && status < 300) || status === 304 || status === 1223;\n\n if (global.onbeforeunload !== undefined)\n browser.Event.detach(global, 'beforeunload', abort);\n\n xhr.onreadystatechange = function() {};\n xhr = null;\n\n if (!successful) return self._handleError(messages);\n\n try {\n replies = JSON.parse(text);\n } catch (error) {}\n\n if (replies)\n self._receive(replies);\n else\n self._handleError(messages);\n };\n\n xhr.send(this.encode(messages));\n return xhr;\n }\n}), {\n isUsable: function(dispatcher, endpoint, callback, context) {\n var usable = (navigator.product === 'ReactNative')\n || URI.isSameOrigin(endpoint);\n\n callback.call(context, usable);\n }\n});\n\nmodule.exports = XHR;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/transport/xhr.js\n ** module id = 29\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n Set = require('../util/set'),\n URI = require('../util/uri'),\n extend = require('../util/extend'),\n toJSON = require('../util/to_json'),\n Transport = require('./transport');\n\nvar CORS = extend(Class(Transport, {\n encode: function(messages) {\n return 'message=' + encodeURIComponent(toJSON(messages));\n },\n\n request: function(messages) {\n var xhrClass = global.XDomainRequest ? XDomainRequest : XMLHttpRequest,\n xhr = new xhrClass(),\n id = ++CORS._id,\n headers = this._dispatcher.headers,\n self = this,\n key;\n\n xhr.open('POST', URI.stringify(this.endpoint), true);\n\n if (xhr.setRequestHeader) {\n xhr.setRequestHeader('Pragma', 'no-cache');\n for (key in headers) {\n if (!headers.hasOwnProperty(key)) continue;\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n\n var cleanUp = function() {\n if (!xhr) return false;\n CORS._pending.remove(id);\n xhr.onload = xhr.onerror = xhr.ontimeout = xhr.onprogress = null;\n xhr = null;\n };\n\n xhr.onload = function() {\n var replies;\n try { replies = JSON.parse(xhr.responseText) } catch (error) {}\n\n cleanUp();\n\n if (replies)\n self._receive(replies);\n else\n self._handleError(messages);\n };\n\n xhr.onerror = xhr.ontimeout = function() {\n cleanUp();\n self._handleError(messages);\n };\n\n xhr.onprogress = function() {};\n\n if (xhrClass === global.XDomainRequest)\n CORS._pending.add({id: id, xhr: xhr});\n\n xhr.send(this.encode(messages));\n return xhr;\n }\n}), {\n _id: 0,\n _pending: new Set(),\n\n isUsable: function(dispatcher, endpoint, callback, context) {\n if (URI.isSameOrigin(endpoint))\n return callback.call(context, false);\n\n if (global.XDomainRequest)\n return callback.call(context, endpoint.protocol === location.protocol);\n\n if (global.XMLHttpRequest) {\n var xhr = new XMLHttpRequest();\n return callback.call(context, xhr.withCredentials !== undefined);\n }\n return callback.call(context, false);\n }\n});\n\nmodule.exports = CORS;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/transport/cors.js\n ** module id = 30\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n copyObject = require('../util/copy_object'),\n extend = require('../util/extend'),\n toJSON = require('../util/to_json'),\n Transport = require('./transport');\n\nvar JSONP = extend(Class(Transport, {\n encode: function(messages) {\n var url = copyObject(this.endpoint);\n url.query.message = toJSON(messages);\n url.query.jsonp = '__jsonp' + JSONP._cbCount + '__';\n return URI.stringify(url);\n },\n\n request: function(messages) {\n var head = document.getElementsByTagName('head')[0],\n script = document.createElement('script'),\n callbackName = JSONP.getCallbackName(),\n endpoint = copyObject(this.endpoint),\n self = this;\n\n endpoint.query.message = toJSON(messages);\n endpoint.query.jsonp = callbackName;\n\n var cleanup = function() {\n if (!global[callbackName]) return false;\n global[callbackName] = undefined;\n try { delete global[callbackName] } catch (error) {}\n script.parentNode.removeChild(script);\n };\n\n global[callbackName] = function(replies) {\n cleanup();\n self._receive(replies);\n };\n\n script.type = 'text/javascript';\n script.src = URI.stringify(endpoint);\n head.appendChild(script);\n\n script.onerror = function() {\n cleanup();\n self._handleError(messages);\n };\n\n return {abort: cleanup};\n }\n}), {\n _cbCount: 0,\n\n getCallbackName: function() {\n this._cbCount += 1;\n return '__jsonp' + this._cbCount + '__';\n },\n\n isUsable: function(dispatcher, endpoint, callback, context) {\n callback.call(context, true);\n }\n});\n\nmodule.exports = JSONP;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/transport/jsonp.js\n ** module id = 31\n ** module chunks = 0\n **/","'use strict';\n\nvar extend = require('../util/extend');\n\nvar Scheduler = function(message, options) {\n this.message = message;\n this.options = options;\n this.attempts = 0;\n};\n\nextend(Scheduler.prototype, {\n getTimeout: function() {\n return this.options.timeout;\n },\n\n getInterval: function() {\n return this.options.interval;\n },\n\n isDeliverable: function() {\n var attempts = this.options.attempts,\n made = this.attempts,\n deadline = this.options.deadline,\n now = new Date().getTime();\n\n if (attempts !== undefined && made >= attempts)\n return false;\n\n if (deadline !== undefined && now > deadline)\n return false;\n\n return true;\n },\n\n send: function() {\n this.attempts += 1;\n },\n\n succeed: function() {},\n\n fail: function() {},\n\n abort: function() {}\n});\n\nmodule.exports = Scheduler;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/scheduler.js\n ** module id = 32\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n Grammar = require('./grammar');\n\nvar Error = Class({\n initialize: function(code, params, message) {\n this.code = code;\n this.params = Array.prototype.slice.call(params);\n this.message = message;\n },\n\n toString: function() {\n return this.code + ':' +\n this.params.join(',') + ':' +\n this.message;\n }\n});\n\nError.parse = function(message) {\n message = message || '';\n if (!Grammar.ERROR.test(message)) return new Error(null, [], message);\n\n var parts = message.split(':'),\n code = parseInt(parts[0]),\n params = parts[1].split(','),\n message = parts[2];\n\n return new Error(code, params, message);\n};\n\n// http://code.google.com/p/cometd/wiki/BayeuxCodes\nvar errors = {\n versionMismatch: [300, 'Version mismatch'],\n conntypeMismatch: [301, 'Connection types not supported'],\n extMismatch: [302, 'Extension mismatch'],\n badRequest: [400, 'Bad request'],\n clientUnknown: [401, 'Unknown client'],\n parameterMissing: [402, 'Missing required parameter'],\n channelForbidden: [403, 'Forbidden channel'],\n channelUnknown: [404, 'Unknown channel'],\n channelInvalid: [405, 'Invalid channel'],\n extUnknown: [406, 'Unknown extension'],\n publishFailed: [407, 'Failed to publish'],\n serverError: [500, 'Internal server error']\n};\n\nfor (var name in errors)\n (function(name) {\n Error[name] = function() {\n return new Error(errors[name][0], arguments, errors[name][1]).toString();\n };\n })(name);\n\nmodule.exports = Error;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/error.js\n ** module id = 33\n ** module chunks = 0\n **/","'use strict';\n\nvar extend = require('../util/extend'),\n Logging = require('../mixins/logging');\n\nvar Extensible = {\n addExtension: function(extension) {\n this._extensions = this._extensions || [];\n this._extensions.push(extension);\n if (extension.added) extension.added(this);\n },\n\n removeExtension: function(extension) {\n if (!this._extensions) return;\n var i = this._extensions.length;\n while (i--) {\n if (this._extensions[i] !== extension) continue;\n this._extensions.splice(i,1);\n if (extension.removed) extension.removed(this);\n }\n },\n\n pipeThroughExtensions: function(stage, message, request, callback, context) {\n this.debug('Passing through ? extensions: ?', stage, message);\n\n if (!this._extensions) return callback.call(context, message);\n var extensions = this._extensions.slice();\n\n var pipe = function(message) {\n if (!message) return callback.call(context, message);\n\n var extension = extensions.shift();\n if (!extension) return callback.call(context, message);\n\n var fn = extension[stage];\n if (!fn) return pipe(message);\n\n if (fn.length >= 3) extension[stage](message, request, pipe);\n else extension[stage](message, pipe);\n };\n pipe(message);\n }\n};\n\nextend(Extensible, Logging);\n\nmodule.exports = Extensible;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/extensible.js\n ** module id = 34\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n Deferrable = require('../mixins/deferrable');\n\nmodule.exports = Class(Deferrable);\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/publication.js\n ** module id = 35\n ** module chunks = 0\n **/","'use strict';\n\nvar Class = require('../util/class'),\n extend = require('../util/extend'),\n Deferrable = require('../mixins/deferrable');\n\nvar Subscription = Class({\n initialize: function(client, channels, callback, context) {\n this._client = client;\n this._channels = channels;\n this._callback = callback;\n this._context = context;\n this._cancelled = false;\n },\n\n withChannel: function(callback, context) {\n this._withChannel = [callback, context];\n return this;\n },\n\n apply: function(context, args) {\n var message = args[0];\n\n if (this._callback)\n this._callback.call(this._context, message.data);\n\n if (this._withChannel)\n this._withChannel[0].call(this._withChannel[1], message.channel, message.data);\n },\n\n cancel: function() {\n if (this._cancelled) return;\n this._client.unsubscribe(this._channels, this);\n this._cancelled = true;\n },\n\n unsubscribe: function() {\n this.cancel();\n }\n});\n\nextend(Subscription.prototype, Deferrable);\n\nmodule.exports = Subscription;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/protocol/subscription.js\n ** module id = 36\n ** module chunks = 0\n **/"],"sourceRoot":""}
|
data/lib/faye.rb
CHANGED
@@ -33,7 +33,7 @@ module Faye
|
|
33
33
|
@endpoint_re = Regexp.new('^' + @endpoint.gsub(/\/$/, '') + '(/[^/]*)*(\\.[^\\.]+)?$')
|
34
34
|
@server = Server.new(@options)
|
35
35
|
|
36
|
-
@static = StaticServer.new(ROOT, /\.(?:js|map)$/)
|
36
|
+
@static = StaticServer.new(File.join(ROOT, '..', 'build', 'client'), /\.(?:js|map)$/)
|
37
37
|
@static.map(File.basename(@endpoint) + '.js', SCRIPT_PATH)
|
38
38
|
@static.map('client.js', SCRIPT_PATH)
|
39
39
|
|
@@ -110,7 +110,7 @@ module Faye
|
|
110
110
|
|
111
111
|
debug("Received message via HTTP #{request.request_method}: ?", json_msg)
|
112
112
|
|
113
|
-
message =
|
113
|
+
message = parse_json(json_msg)
|
114
114
|
jsonp = request.params['jsonp'] || JSONP_CALLBACK
|
115
115
|
headers = request.get? ? TYPE_SCRIPT.dup : TYPE_JSON.dup
|
116
116
|
origin = request.env['HTTP_ORIGIN']
|
@@ -138,7 +138,6 @@ module Faye
|
|
138
138
|
end
|
139
139
|
|
140
140
|
headers['Content-Length'] = response.bytesize.to_s unless request.env[HTTP_X_NO_CONTENT_LENGTH]
|
141
|
-
headers['Connection'] = 'close'
|
142
141
|
debug('HTTP response: ?', response)
|
143
142
|
send_response([200, headers, [response]], hijack, callback)
|
144
143
|
end
|
@@ -196,7 +195,7 @@ module Faye
|
|
196
195
|
begin
|
197
196
|
debug("Received message via WebSocket[#{ws.version}]: ?", event.data)
|
198
197
|
|
199
|
-
message =
|
198
|
+
message = parse_json(event.data)
|
200
199
|
cid = Faye.client_id_from_messages(message)
|
201
200
|
|
202
201
|
@server.close_socket(client_id, false) if client_id and cid and cid != client_id
|
@@ -245,6 +244,12 @@ module Faye
|
|
245
244
|
[200, headers, []]
|
246
245
|
end
|
247
246
|
|
247
|
+
def parse_json(json)
|
248
|
+
data = MultiJson.load(json)
|
249
|
+
return data if Array === data or Hash === data
|
250
|
+
raise ArgumentError, 'JSON messages must contain an object or array'
|
251
|
+
end
|
252
|
+
|
248
253
|
def format_request(request)
|
249
254
|
request.body.rewind
|
250
255
|
string = "curl -X #{request.request_method.upcase}"
|
@@ -91,17 +91,17 @@ module Faye
|
|
91
91
|
@channels.has_key?(name)
|
92
92
|
end
|
93
93
|
|
94
|
-
def subscribe(names,
|
94
|
+
def subscribe(names, subscription)
|
95
95
|
names.each do |name|
|
96
96
|
channel = @channels[name] ||= Channel.new(name)
|
97
|
-
channel.bind(:message, &
|
97
|
+
channel.bind(:message, &subscription)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
def unsubscribe(name,
|
101
|
+
def unsubscribe(name, subscription)
|
102
102
|
channel = @channels[name]
|
103
103
|
return false unless channel
|
104
|
-
channel.unbind(:message, &
|
104
|
+
channel.unbind(:message, &subscription)
|
105
105
|
if channel.unused?
|
106
106
|
remove(name)
|
107
107
|
true
|
@@ -114,7 +114,7 @@ module Faye
|
|
114
114
|
channels = Channel.expand(message['channel'])
|
115
115
|
channels.each do |name|
|
116
116
|
channel = @channels[name]
|
117
|
-
channel.trigger(:message, message
|
117
|
+
channel.trigger(:message, message) if channel
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
data/lib/faye/protocol/client.rb
CHANGED
@@ -25,9 +25,8 @@ module Faye
|
|
25
25
|
super()
|
26
26
|
info('New client created for ?', endpoint)
|
27
27
|
|
28
|
-
@endpoint = endpoint || RackAdapter::DEFAULT_ENDPOINT
|
29
28
|
@channels = Channel::Set.new
|
30
|
-
@dispatcher = Dispatcher.new(self,
|
29
|
+
@dispatcher = Dispatcher.new(self, endpoint || RackAdapter::DEFAULT_ENDPOINT, options)
|
31
30
|
|
32
31
|
@message_id = 0
|
33
32
|
@state = UNCONNECTED
|
@@ -69,7 +68,7 @@ module Faye
|
|
69
68
|
|
70
69
|
@state = CONNECTING
|
71
70
|
|
72
|
-
info('Initiating handshake with ?', @endpoint)
|
71
|
+
info('Initiating handshake with ?', @dispatcher.endpoint.to_s)
|
73
72
|
@dispatcher.select_transport(MANDATORY_CONNECTION_TYPES)
|
74
73
|
|
75
74
|
send_message({
|
@@ -187,14 +186,14 @@ module Faye
|
|
187
186
|
has_subscribe = @channels.has_subscription?(channel)
|
188
187
|
|
189
188
|
if has_subscribe and not force
|
190
|
-
@channels.subscribe([channel],
|
189
|
+
@channels.subscribe([channel], subscription)
|
191
190
|
subscription.set_deferred_status(:succeeded)
|
192
191
|
return subscription
|
193
192
|
end
|
194
193
|
|
195
194
|
connect {
|
196
195
|
info('Client ? attempting to subscribe to ?', @dispatcher.client_id, channel)
|
197
|
-
@channels.subscribe([channel],
|
196
|
+
@channels.subscribe([channel], subscription) unless force
|
198
197
|
|
199
198
|
send_message({
|
200
199
|
'channel' => Channel::SUBSCRIBE,
|
@@ -204,7 +203,7 @@ module Faye
|
|
204
203
|
}, {}) do |response|
|
205
204
|
unless response['successful']
|
206
205
|
subscription.set_deferred_status(:failed, Error.parse(response['error']))
|
207
|
-
next @channels.unsubscribe(channel,
|
206
|
+
next @channels.unsubscribe(channel, subscription)
|
208
207
|
end
|
209
208
|
|
210
209
|
channels = [response['subscription']].flatten
|
@@ -225,12 +224,14 @@ module Faye
|
|
225
224
|
# * ext
|
226
225
|
# * id
|
227
226
|
# * timestamp
|
228
|
-
def unsubscribe(channel, &block)
|
227
|
+
def unsubscribe(channel, subscription = nil, &block)
|
228
|
+
subscription ||= block
|
229
|
+
|
229
230
|
if Array === channel
|
230
|
-
return channel.map { |c| unsubscribe(c,
|
231
|
+
return channel.map { |c| unsubscribe(c, subscription) }
|
231
232
|
end
|
232
233
|
|
233
|
-
dead = @channels.unsubscribe(channel,
|
234
|
+
dead = @channels.unsubscribe(channel, subscription)
|
234
235
|
return unless dead
|
235
236
|
|
236
237
|
connect {
|
data/lib/faye/protocol/server.rb
CHANGED
@@ -6,6 +6,8 @@ module Faye
|
|
6
6
|
include Logging
|
7
7
|
include Extensible
|
8
8
|
|
9
|
+
META_METHODS = %w[handshake connect disconnect subscribe unsubscribe]
|
10
|
+
|
9
11
|
attr_reader :engine
|
10
12
|
|
11
13
|
def initialize(options = {})
|
@@ -101,9 +103,9 @@ module Faye
|
|
101
103
|
end
|
102
104
|
|
103
105
|
def handle_meta(message, local, &callback)
|
104
|
-
method =
|
106
|
+
method = Channel.parse(message['channel'])[1]
|
105
107
|
|
106
|
-
unless method
|
108
|
+
unless META_METHODS.include?(method)
|
107
109
|
response = make_response(message)
|
108
110
|
response['error'] = Faye::Error.channel_forbidden(message['channel'])
|
109
111
|
response['successful'] = false
|
@@ -117,16 +119,6 @@ module Faye
|
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
120
|
-
def method_for(message)
|
121
|
-
case message['channel']
|
122
|
-
when Channel::HANDSHAKE then :handshake
|
123
|
-
when Channel::CONNECT then :connect
|
124
|
-
when Channel::SUBSCRIBE then :subscribe
|
125
|
-
when Channel::UNSUBSCRIBE then :unsubscribe
|
126
|
-
when Channel::DISCONNECT then :disconnect
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
122
|
def advize(response, connection_type)
|
131
123
|
return unless [Channel::HANDSHAKE, Channel::CONNECT].include?(response['channel'])
|
132
124
|
|
@@ -9,9 +9,25 @@ module Faye
|
|
9
9
|
@cancelled = false
|
10
10
|
end
|
11
11
|
|
12
|
+
def with_channel(&callback)
|
13
|
+
@with_channel = callback
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(*args)
|
18
|
+
message = args.first
|
19
|
+
|
20
|
+
@callback.call(message['data']) if @callback
|
21
|
+
@with_channel.call(message['channel'], message['data']) if @with_channel
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_proc
|
25
|
+
@to_proc ||= lambda { |*a| call(*a) }
|
26
|
+
end
|
27
|
+
|
12
28
|
def cancel
|
13
29
|
return if @cancelled
|
14
|
-
@client.unsubscribe(@channels,
|
30
|
+
@client.unsubscribe(@channels, self)
|
15
31
|
@cancelled = true
|
16
32
|
end
|
17
33
|
|
data/lib/faye/transport/http.rb
CHANGED
@@ -48,7 +48,10 @@ module Faye
|
|
48
48
|
|
49
49
|
def create_request(params)
|
50
50
|
version = EventMachine::HttpRequest::VERSION.split('.')[0].to_i
|
51
|
-
options = {
|
51
|
+
options = {
|
52
|
+
:inactivity_timeout => 0,
|
53
|
+
:tls => {:sni_hostname => @endpoint.hostname}
|
54
|
+
}
|
52
55
|
|
53
56
|
if @proxy[:origin]
|
54
57
|
uri = URI.parse(@proxy[:origin])
|
data/lib/faye/transport/local.rb
CHANGED
@@ -10,8 +10,10 @@ module Faye
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def request(messages)
|
13
|
-
|
14
|
-
|
13
|
+
EventMachine.next_tick do
|
14
|
+
@endpoint.process(messages, nil) do |replies|
|
15
|
+
receive(Faye.copy_object(replies))
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -49,24 +49,32 @@ module Faye
|
|
49
49
|
end
|
50
50
|
|
51
51
|
@outbox << message
|
52
|
-
@promise ||= EventMachine::DefaultDeferrable.new
|
53
52
|
flush_large_batch
|
54
53
|
|
55
54
|
if message['channel'] == Channel::HANDSHAKE
|
56
|
-
|
57
|
-
return @promise
|
55
|
+
return publish(0.01)
|
58
56
|
end
|
59
57
|
|
60
58
|
if message['channel'] == Channel::CONNECT
|
61
59
|
@connection_message = message
|
62
60
|
end
|
63
61
|
|
64
|
-
|
65
|
-
@promise
|
62
|
+
publish(Engine::MAX_DELAY)
|
66
63
|
end
|
67
64
|
|
68
65
|
private
|
69
66
|
|
67
|
+
def publish(delay)
|
68
|
+
@promise ||= EventMachine::DefaultDeferrable.new
|
69
|
+
|
70
|
+
add_timeout(:publish, delay) do
|
71
|
+
flush
|
72
|
+
@promise = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
@promise
|
76
|
+
end
|
77
|
+
|
70
78
|
def flush
|
71
79
|
remove_timeout(:publish)
|
72
80
|
|
@@ -75,7 +83,6 @@ module Faye
|
|
75
83
|
end
|
76
84
|
|
77
85
|
@promise.succeed(request(@outbox))
|
78
|
-
@promise = nil
|
79
86
|
|
80
87
|
@connection_message = nil
|
81
88
|
@outbox = []
|
@@ -85,7 +92,10 @@ module Faye
|
|
85
92
|
string = encode(@outbox)
|
86
93
|
return if string.size < @dispatcher.max_request_size
|
87
94
|
last = @outbox.pop
|
95
|
+
|
96
|
+
@promise ||= EventMachine::DefaultDeferrable.new
|
88
97
|
flush
|
98
|
+
|
89
99
|
@outbox.push(last) if last
|
90
100
|
end
|
91
101
|
|
@@ -46,7 +46,7 @@ module Faye
|
|
46
46
|
promise = Request.new
|
47
47
|
|
48
48
|
callback do |socket|
|
49
|
-
next unless socket
|
49
|
+
next unless socket and socket.ready_state == 1
|
50
50
|
socket.send(Faye.to_json(messages))
|
51
51
|
promise.succeed(socket)
|
52
52
|
end
|
@@ -68,8 +68,14 @@ module Faye
|
|
68
68
|
url.scheme = PROTOCOLS[url.scheme]
|
69
69
|
headers['Cookie'] = cookie unless cookie == ''
|
70
70
|
|
71
|
-
options = {
|
72
|
-
|
71
|
+
options = {
|
72
|
+
:extensions => extensions,
|
73
|
+
:headers => headers,
|
74
|
+
:proxy => @proxy,
|
75
|
+
:tls => {:sni_hostname => url.hostname}
|
76
|
+
}
|
77
|
+
|
78
|
+
socket = Faye::WebSocket::Client.new(url.to_s, [], options)
|
73
79
|
|
74
80
|
socket.onopen = lambda do |*args|
|
75
81
|
store_cookies(socket.headers['Set-Cookie'])
|
@@ -91,22 +97,20 @@ module Faye
|
|
91
97
|
@socket = nil
|
92
98
|
@state = UNCONNECTED
|
93
99
|
remove_timeout(:ping)
|
94
|
-
set_deferred_status(:unknown)
|
95
100
|
|
96
101
|
pending = @pending ? @pending.to_a : []
|
97
102
|
@pending = nil
|
98
103
|
|
99
|
-
if was_connected
|
100
|
-
|
101
|
-
|
102
|
-
handle_error(pending)
|
104
|
+
if was_connected or @ever_connected
|
105
|
+
set_deferred_status(:unknown)
|
106
|
+
handle_error(pending, was_connected)
|
103
107
|
else
|
104
108
|
set_deferred_status(:failed)
|
105
109
|
end
|
106
110
|
end
|
107
111
|
|
108
112
|
socket.onmessage = lambda do |event|
|
109
|
-
replies = MultiJson.load(event.data)
|
113
|
+
replies = MultiJson.load(event.data) rescue nil
|
110
114
|
next if replies.nil?
|
111
115
|
replies = [replies].flatten
|
112
116
|
|
@@ -127,7 +131,7 @@ module Faye
|
|
127
131
|
private
|
128
132
|
|
129
133
|
def ping
|
130
|
-
return unless @socket
|
134
|
+
return unless @socket and @socket.ready_state == 1
|
131
135
|
@socket.send('[]')
|
132
136
|
add_timeout(:ping, @dispatcher.timeout / 2) { ping }
|
133
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Coglan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cookiejar
|
@@ -355,9 +355,10 @@ extra_rdoc_files:
|
|
355
355
|
files:
|
356
356
|
- CHANGELOG.md
|
357
357
|
- README.md
|
358
|
-
-
|
359
|
-
-
|
360
|
-
-
|
358
|
+
- build/client/faye-browser-min.js
|
359
|
+
- build/client/faye-browser-min.js.map
|
360
|
+
- build/client/faye-browser.js
|
361
|
+
- build/client/faye-browser.js.map
|
361
362
|
- lib/faye.rb
|
362
363
|
- lib/faye/adapters/rack_adapter.rb
|
363
364
|
- lib/faye/adapters/static_server.rb
|
@@ -384,7 +385,7 @@ files:
|
|
384
385
|
- lib/faye/transport/transport.rb
|
385
386
|
- lib/faye/transport/web_socket.rb
|
386
387
|
- lib/faye/util/namespace.rb
|
387
|
-
homepage:
|
388
|
+
homepage: https://faye.jcoglan.com
|
388
389
|
licenses:
|
389
390
|
- MIT
|
390
391
|
metadata: {}
|
@@ -407,7 +408,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
408
|
- !ruby/object:Gem::Version
|
408
409
|
version: '0'
|
409
410
|
requirements: []
|
410
|
-
|
411
|
+
rubyforge_project:
|
412
|
+
rubygems_version: 2.5.1
|
411
413
|
signing_key:
|
412
414
|
specification_version: 4
|
413
415
|
summary: Simple pub/sub messaging for the web
|
data/lib/faye-browser-min.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
!function(){"use strict";var Faye={VERSION:"1.1.3",BAYEUX_VERSION:"1.0",ID_LENGTH:160,JSONP_CALLBACK:"jsonpcallback",CONNECTION_TYPES:["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],MANDATORY_CONNECTION_TYPES:["long-polling","callback-polling","in-process"],ENV:"undefined"!=typeof window?window:global,extend:function(e,t,n){if(!t)return e;for(var i in t)t.hasOwnProperty(i)&&(e.hasOwnProperty(i)&&!1===n||e[i]!==t[i]&&(e[i]=t[i]));return e},random:function(e){e=e||this.ID_LENGTH;for(var t=Math.ceil(e*Math.log(2)/Math.log(36)),n=csprng(e,36);n.length<t;)n="0"+n;return n},validateOptions:function(e,t){for(var n in e)if(this.indexOf(t,n)<0)throw Error("Unrecognized option: "+n)},clientIdFromMessages:function(e){var t=this.filter([].concat(e),function(e){return"/meta/connect"===e.channel});return t[0]&&t[0].clientId},copyObject:function(e){var t,n,i;if(e instanceof Array){for(t=[],n=e.length;n--;)t[n]=Faye.copyObject(e[n]);return t}if("object"==typeof e){t=null===e?null:{};for(i in e)t[i]=Faye.copyObject(e[i]);return t}return e},commonElement:function(e,t){for(var n=0,i=e.length;n<i;n++)if(-1!==this.indexOf(t,e[n]))return e[n];return null},indexOf:function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return n;return-1},map:function(e,t,n){if(e.map)return e.map(t,n);var i=[];if(e instanceof Array)for(var s=0,r=e.length;s<r;s++)i.push(t.call(n||null,e[s],s));else for(var o in e)e.hasOwnProperty(o)&&i.push(t.call(n||null,o,e[o]));return i},filter:function(e,t,n){if(e.filter)return e.filter(t,n);for(var i=[],s=0,r=e.length;s<r;s++)t.call(n||null,e[s],s)&&i.push(e[s]);return i},asyncEach:function(e,t,n,i){var s=e.length,r=-1,o=0,a=!1,c=function(){if(o-=1,(r+=1)===s)return n&&n.call(i);t(e[r],u)},h=function(){if(!a){for(a=!0;o>0;)c();a=!1}},u=function(){o+=1,h()};u()},toJSON:function(e){return this.stringify?this.stringify(e,function(e,t){return this[e]instanceof Array?this[e]:t}):JSON.stringify(e)}};"undefined"!=typeof module?module.exports=Faye:"undefined"!=typeof window&&(window.Faye=Faye),Faye.Class=function(e,t){"function"!=typeof e&&(t=e,e=Object);var n=function(){return this.initialize?this.initialize.apply(this,arguments)||this:this},i=function(){};return i.prototype=e.prototype,n.prototype=new i,Faye.extend(n.prototype,t),n},function(){function e(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(t===e[n])return n;return-1}var t=Faye.EventEmitter=function(){},n="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};t.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||n(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var i=Array.prototype.slice.call(arguments,1);t.apply(this,i)}return!0}if(n(t)){for(var i=Array.prototype.slice.call(arguments,1),s=t.slice(),r=0,o=s.length;r<o;r++)s[r].apply(this,i);return!0}return!1},t.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");return this._events||(this._events={}),this.emit("newListener",e,t),this._events[e]?n(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){var n=this;return n.on(e,function i(){n.removeListener(e,i),t.apply(this,arguments)}),this},t.prototype.removeListener=function(t,i){if("function"!=typeof i)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var s=this._events[t];if(n(s)){var r=e(s,i);if(r<0)return this;s.splice(r,1),0==s.length&&delete this._events[t]}else this._events[t]===i&&delete this._events[t];return this},t.prototype.removeAllListeners=function(e){return 0===arguments.length?(this._events={},this):(e&&this._events&&this._events[e]&&(this._events[e]=null),this)},t.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),n(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}}(),Faye.Namespace=Faye.Class({initialize:function(){this._used={}},exists:function(e){return this._used.hasOwnProperty(e)},generate:function(){for(var e=Faye.random();this._used.hasOwnProperty(e);)e=Faye.random();return this._used[e]=e},release:function(e){delete this._used[e]}}),function(){var e,t=setTimeout;e="function"==typeof setImmediate?function(e){setImmediate(e)}:"object"==typeof process&&process.nextTick?function(e){process.nextTick(e)}:function(e){t(e,0)};var n=0,i=1,s=2,r=function(e){return e},o=function(e){throw e},a=function(e){if(this._state=n,this._onFulfilled=[],this._onRejected=[],"function"==typeof e){var t=this;e(function(e){f(t,e)},function(e){d(t,e)})}};a.prototype.then=function(e,t){var n=new a;return c(this,e,n),h(this,t,n),n};var c=function(e,t,s){"function"!=typeof t&&(t=r);var o=function(e){u(t,e,s)};e._state===n?e._onFulfilled.push(o):e._state===i&&o(e._value)},h=function(e,t,i){"function"!=typeof t&&(t=o);var r=function(e){u(t,e,i)};e._state===n?e._onRejected.push(r):e._state===s&&r(e._reason)},u=function(t,n,i){e(function(){l(t,n,i)})},l=function(e,t,n){var i;try{i=e(t)}catch(e){return d(n,e)}i===n?d(n,new TypeError("Recursive promise chain detected")):f(n,i)},f=a.fulfill=a.resolve=function(e,t){var n,i,s=!1;try{if(n=typeof t,"function"!=typeof(i=null!==t&&("function"===n||"object"===n)&&t.then))return p(e,t);i.call(t,function(t){s^(s=!0)&&f(e,t)},function(t){s^(s=!0)&&d(e,t)})}catch(t){if(!(s^(s=!0)))return;d(e,t)}},p=function(e,t){if(e._state===n){e._state=i,e._value=t,e._onRejected=[];for(var s,r=e._onFulfilled;s=r.shift();)s(t)}},d=a.reject=function(e,t){if(e._state===n){e._state=s,e._reason=t,e._onFulfilled=[];for(var i,r=e._onRejected;i=r.shift();)i(t)}};a.all=function(e){return new a(function(t,n){var i,s=[],r=e.length;if(0===r)return t(s);for(i=0;i<r;i++)!function(e,i){a.fulfilled(e).then(function(e){s[i]=e,0==--r&&t(s)},n)}(e[i],i)})},a.defer=e,a.deferred=a.pending=function(){var e={};return e.promise=new a(function(t,n){e.fulfill=e.resolve=t,e.reject=n}),e},a.fulfilled=a.resolved=function(e){return new a(function(t,n){t(e)})},a.rejected=function(e){return new a(function(t,n){n(e)})},void 0===Faye?module.exports=a:Faye.Promise=a}(),Faye.Set=Faye.Class({initialize:function(){this._index={}},add:function(e){var t=void 0!==e.id?e.id:e;return!this._index.hasOwnProperty(t)&&(this._index[t]=e,!0)},forEach:function(e,t){for(var n in this._index)this._index.hasOwnProperty(n)&&e.call(t,this._index[n])},isEmpty:function(){for(var e in this._index)if(this._index.hasOwnProperty(e))return!1;return!0},member:function(e){for(var t in this._index)if(this._index[t]===e)return!0;return!1},remove:function(e){var t=void 0!==e.id?e.id:e,n=this._index[t];return delete this._index[t],n},toArray:function(){var e=[];return this.forEach(function(t){e.push(t)}),e}}),Faye.URI={isURI:function(e){return e&&e.protocol&&e.host&&e.path},isSameOrigin:function(e){var t=Faye.ENV.location;return e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port},parse:function(e){if("string"!=typeof e)return e;var t,n,i,s,r,o,a={},c=function(t,n){e=e.replace(n,function(e){return a[t]=e,""}),a[t]=a[t]||""};for(c("protocol",/^[a-z]+\:/i),c("host",/^\/\/[^\/\?#]+/),/^\//.test(e)||a.host||(e=Faye.ENV.location.pathname.replace(/[^\/]*$/,"")+e),c("pathname",/^[^\?#]*/),c("search",/^\?[^#]*/),c("hash",/^#.*/),a.protocol=a.protocol||Faye.ENV.location.protocol,a.host?(a.host=a.host.substr(2),t=a.host.split(":"),a.hostname=t[0],a.port=t[1]||""):(a.host=Faye.ENV.location.host,a.hostname=Faye.ENV.location.hostname,a.port=Faye.ENV.location.port),a.pathname=a.pathname||"/",a.path=a.pathname+a.search,n=a.search.replace(/^\?/,""),i=n?n.split("&"):[],o={},s=0,r=i.length;s<r;s++)t=i[s].split("="),o[decodeURIComponent(t[0]||"")]=decodeURIComponent(t[1]||"");return a.query=o,a.href=this.stringify(a),a},stringify:function(e){var t=e.protocol+"//"+e.hostname;return e.port&&(t+=":"+e.port),t+=e.pathname+this.queryString(e.query)+(e.hash||"")},queryString:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return 0===t.length?"":"?"+t.join("&")}},Faye.Error=Faye.Class({initialize:function(e,t,n){this.code=e,this.params=Array.prototype.slice.call(t),this.message=n},toString:function(){return this.code+":"+this.params.join(",")+":"+this.message}}),Faye.Error.parse=function(e){if(e=e||"",!Faye.Grammar.ERROR.test(e))return new this(null,[],e);var t=e.split(":"),n=parseInt(t[0]),i=t[1].split(","),e=t[2];return new this(n,i,e)},Faye.Error.versionMismatch=function(){return""+new this(300,arguments,"Version mismatch")},Faye.Error.conntypeMismatch=function(){return""+new this(301,arguments,"Connection types not supported")},Faye.Error.extMismatch=function(){return""+new this(302,arguments,"Extension mismatch")},Faye.Error.badRequest=function(){return""+new this(400,arguments,"Bad request")},Faye.Error.clientUnknown=function(){return""+new this(401,arguments,"Unknown client")},Faye.Error.parameterMissing=function(){return""+new this(402,arguments,"Missing required parameter")},Faye.Error.channelForbidden=function(){return""+new this(403,arguments,"Forbidden channel")},Faye.Error.channelUnknown=function(){return""+new this(404,arguments,"Unknown channel")},Faye.Error.channelInvalid=function(){return""+new this(405,arguments,"Invalid channel")},Faye.Error.extUnknown=function(){return""+new this(406,arguments,"Unknown extension")},Faye.Error.publishFailed=function(){return""+new this(407,arguments,"Failed to publish")},Faye.Error.serverError=function(){return""+new this(500,arguments,"Internal server error")},Faye.Deferrable={then:function(e,t){var n=this;return this._promise||(this._promise=new Faye.Promise(function(e,t){n._fulfill=e,n._reject=t})),0===arguments.length?this._promise:this._promise.then(e,t)},callback:function(e,t){return this.then(function(n){e.call(t,n)})},errback:function(e,t){return this.then(null,function(n){e.call(t,n)})},timeout:function(e,t){this.then();var n=this;this._timer=Faye.ENV.setTimeout(function(){n._reject(t)},1e3*e)},setDeferredStatus:function(e,t){this._timer&&Faye.ENV.clearTimeout(this._timer),this.then(),"succeeded"===e?this._fulfill(t):"failed"===e?this._reject(t):delete this._promise}},Faye.Publisher={countListeners:function(e){return this.listeners(e).length},bind:function(e,t,n){var i=Array.prototype.slice,s=function(){t.apply(n,i.call(arguments))};return this._listeners=this._listeners||[],this._listeners.push([e,t,n,s]),this.on(e,s)},unbind:function(e,t,n){this._listeners=this._listeners||[];for(var i,s=this._listeners.length;s--;)i=this._listeners[s],i[0]===e&&(!t||i[1]===t&&i[2]===n)&&(this._listeners.splice(s,1),this.removeListener(e,i[3]))}},Faye.extend(Faye.Publisher,Faye.EventEmitter.prototype),Faye.Publisher.trigger=Faye.Publisher.emit,Faye.Timeouts={addTimeout:function(e,t,n,i){if(this._timeouts=this._timeouts||{},!this._timeouts.hasOwnProperty(e)){var s=this;this._timeouts[e]=Faye.ENV.setTimeout(function(){delete s._timeouts[e],n.call(i)},1e3*t)}},removeTimeout:function(e){this._timeouts=this._timeouts||{};var t=this._timeouts[e];t&&(Faye.ENV.clearTimeout(t),delete this._timeouts[e])},removeAllTimeouts:function(){this._timeouts=this._timeouts||{};for(var e in this._timeouts)this.removeTimeout(e)}},Faye.Logging={LOG_LEVELS:{fatal:4,error:3,warn:2,info:1,debug:0},writeLog:function(e,t){if(Faye.logger){var n=Array.prototype.slice.apply(e),i="[Faye",s=this.className,r=n.shift().replace(/\?/g,function(){try{return Faye.toJSON(n.shift())}catch(e){return"[Object]"}});for(var o in Faye)s||"function"==typeof Faye[o]&&this instanceof Faye[o]&&(s=o);s&&(i+="."+s),i+="] ","function"==typeof Faye.logger[t]?Faye.logger[t](i+r):"function"==typeof Faye.logger&&Faye.logger(i+r)}}},function(){for(var e in Faye.Logging.LOG_LEVELS)!function(e){Faye.Logging[e]=function(){this.writeLog(arguments,e)}}(e)}(),Faye.Grammar={CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/},Faye.Extensible={addExtension:function(e){this._extensions=this._extensions||[],this._extensions.push(e),e.added&&e.added(this)},removeExtension:function(e){if(this._extensions)for(var t=this._extensions.length;t--;)this._extensions[t]===e&&(this._extensions.splice(t,1),e.removed&&e.removed(this))},pipeThroughExtensions:function(e,t,n,i,s){if(this.debug("Passing through ? extensions: ?",e,t),!this._extensions)return i.call(s,t);var r=this._extensions.slice(),o=function(t){if(!t)return i.call(s,t);var a=r.shift();if(!a)return i.call(s,t);var c=a[e];if(!c)return o(t);c.length>=3?a[e](t,n,o):a[e](t,o)};o(t)}},Faye.extend(Faye.Extensible,Faye.Logging),Faye.Channel=Faye.Class({initialize:function(e){this.id=this.name=e},push:function(e){this.trigger("message",e)},isUnused:function(){return 0===this.countListeners("message")}}),Faye.extend(Faye.Channel.prototype,Faye.Publisher),Faye.extend(Faye.Channel,{HANDSHAKE:"/meta/handshake",CONNECT:"/meta/connect",SUBSCRIBE:"/meta/subscribe",UNSUBSCRIBE:"/meta/unsubscribe",DISCONNECT:"/meta/disconnect",META:"meta",SERVICE:"service",expand:function(e){var t=this.parse(e),n=["/**",e],i=t.slice();i[i.length-1]="*",n.push(this.unparse(i));for(var s=1,r=t.length;s<r;s++)i=t.slice(0,s),i.push("**"),n.push(this.unparse(i));return n},isValid:function(e){return Faye.Grammar.CHANNEL_NAME.test(e)||Faye.Grammar.CHANNEL_PATTERN.test(e)},parse:function(e){return this.isValid(e)?e.split("/").slice(1):null},unparse:function(e){return"/"+e.join("/")},isMeta:function(e){var t=this.parse(e);return t?t[0]===this.META:null},isService:function(e){var t=this.parse(e);return t?t[0]===this.SERVICE:null},isSubscribable:function(e){return this.isValid(e)?!this.isMeta(e)&&!this.isService(e):null},Set:Faye.Class({initialize:function(){this._channels={}},getKeys:function(){var e=[];for(var t in this._channels)e.push(t);return e},remove:function(e){delete this._channels[e]},hasSubscription:function(e){return this._channels.hasOwnProperty(e)},subscribe:function(e,t,n){for(var i,s=0,r=e.length;s<r;s++){i=e[s];var o=this._channels[i]=this._channels[i]||new Faye.Channel(i);t&&o.bind("message",t,n)}},unsubscribe:function(e,t,n){var i=this._channels[e];return!!i&&(i.unbind("message",t,n),!!i.isUnused()&&(this.remove(e),!0))},distributeMessage:function(e){for(var t=Faye.Channel.expand(e.channel),n=0,i=t.length;n<i;n++){var s=this._channels[t[n]];s&&s.trigger("message",e.data)}}})}),Faye.Publication=Faye.Class(Faye.Deferrable),Faye.Subscription=Faye.Class({initialize:function(e,t,n,i){this._client=e,this._channels=t,this._callback=n,this._context=i,this._cancelled=!1},cancel:function(){this._cancelled||(this._client.unsubscribe(this._channels,this._callback,this._context),this._cancelled=!0)},unsubscribe:function(){this.cancel()}}),Faye.extend(Faye.Subscription.prototype,Faye.Deferrable),Faye.Client=Faye.Class({UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:"handshake",RETRY:"retry",NONE:"none",CONNECTION_TIMEOUT:60,DEFAULT_ENDPOINT:"/bayeux",INTERVAL:0,initialize:function(e,t){this.info("New client created for ?",e),t=t||{},Faye.validateOptions(t,["interval","timeout","endpoints","proxy","retry","scheduler","websocketExtensions","tls","ca"]),this._endpoint=e||this.DEFAULT_ENDPOINT,this._channels=new Faye.Channel.Set,this._dispatcher=new Faye.Dispatcher(this,this._endpoint,t),this._messageId=0,this._state=this.UNCONNECTED,this._responseCallbacks={},this._advice={reconnect:this.RETRY,interval:1e3*(t.interval||this.INTERVAL),timeout:1e3*(t.timeout||this.CONNECTION_TIMEOUT)},this._dispatcher.timeout=this._advice.timeout/1e3,this._dispatcher.bind("message",this._receiveMessage,this),Faye.Event&&void 0!==Faye.ENV.onbeforeunload&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.indexOf(this._dispatcher._disabled,"autodisconnect")<0&&this.disconnect()},this)},addWebsocketExtension:function(e){return this._dispatcher.addWebsocketExtension(e)},disable:function(e){return this._dispatcher.disable(e)},setHeader:function(e,t){return this._dispatcher.setHeader(e,t)},handshake:function(e,t){if(this._advice.reconnect!==this.NONE&&this._state===this.UNCONNECTED){this._state=this.CONNECTING;var n=this;this.info("Initiating handshake with ?",Faye.URI.stringify(this._endpoint)),this._dispatcher.selectTransport(Faye.MANDATORY_CONNECTION_TYPES),this._sendMessage({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:this._dispatcher.getConnectionTypes()},{},function(i){i.successful?(this._state=this.CONNECTED,this._dispatcher.clientId=i.clientId,this._dispatcher.selectTransport(i.supportedConnectionTypes),this.info("Handshake successful: ?",this._dispatcher.clientId),this.subscribe(this._channels.getKeys(),!0),e&&Faye.Promise.defer(function(){e.call(t)})):(this.info("Handshake unsuccessful"),Faye.ENV.setTimeout(function(){n.handshake(e,t)},1e3*this._dispatcher.retry),this._state=this.UNCONNECTED)},this)}},connect:function(e,t){if(this._advice.reconnect!==this.NONE&&this._state!==this.DISCONNECTED){if(this._state===this.UNCONNECTED)return this.handshake(function(){this.connect(e,t)},this);this.callback(e,t),this._state===this.CONNECTED&&(this.info("Calling deferred actions for ?",this._dispatcher.clientId),this.setDeferredStatus("succeeded"),this.setDeferredStatus("unknown"),this._connectRequest||(this._connectRequest=!0,this.info("Initiating connection for ?",this._dispatcher.clientId),this._sendMessage({channel:Faye.Channel.CONNECT,clientId:this._dispatcher.clientId,connectionType:this._dispatcher.connectionType},{},this._cycleConnection,this)))}},disconnect:function(){if(this._state===this.CONNECTED){this._state=this.DISCONNECTED,this.info("Disconnecting ?",this._dispatcher.clientId);var e=new Faye.Publication;return this._sendMessage({channel:Faye.Channel.DISCONNECT,clientId:this._dispatcher.clientId},{},function(t){t.successful?(this._dispatcher.close(),e.setDeferredStatus("succeeded")):e.setDeferredStatus("failed",Faye.Error.parse(t.error))},this),this.info("Clearing channel listeners for ?",this._dispatcher.clientId),this._channels=new Faye.Channel.Set,e}},subscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.subscribe(e,t,n)},this);var i=new Faye.Subscription(this,e,t,n),s=!0===t;return this._channels.hasSubscription(e)&&!s?(this._channels.subscribe([e],t,n),i.setDeferredStatus("succeeded"),i):(this.connect(function(){this.info("Client ? attempting to subscribe to ?",this._dispatcher.clientId,e),s||this._channels.subscribe([e],t,n),this._sendMessage({channel:Faye.Channel.SUBSCRIBE,clientId:this._dispatcher.clientId,subscription:e},{},function(s){if(!s.successful)return i.setDeferredStatus("failed",Faye.Error.parse(s.error)),this._channels.unsubscribe(e,t,n);var r=[].concat(s.subscription);this.info("Subscription acknowledged for ? to ?",this._dispatcher.clientId,r),i.setDeferredStatus("succeeded")},this)},this),i)},unsubscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.unsubscribe(e,t,n)},this);this._channels.unsubscribe(e,t,n)&&this.connect(function(){this.info("Client ? attempting to unsubscribe from ?",this._dispatcher.clientId,e),this._sendMessage({channel:Faye.Channel.UNSUBSCRIBE,clientId:this._dispatcher.clientId,subscription:e},{},function(e){if(e.successful){var t=[].concat(e.subscription);this.info("Unsubscription acknowledged for ? from ?",this._dispatcher.clientId,t)}},this)},this)},publish:function(e,t,n){Faye.validateOptions(n||{},["attempts","deadline"]);var i=new Faye.Publication;return this.connect(function(){this.info("Client ? queueing published message to ?: ?",this._dispatcher.clientId,e,t),this._sendMessage({channel:e,data:t,clientId:this._dispatcher.clientId},n,function(e){e.successful?i.setDeferredStatus("succeeded"):i.setDeferredStatus("failed",Faye.Error.parse(e.error))},this)},this),i},_sendMessage:function(e,t,n,i){e.id=this._generateMessageId();var s=this._advice.timeout?1.2*this._advice.timeout/1e3:1.2*this._dispatcher.retry;this.pipeThroughExtensions("outgoing",e,null,function(e){e&&(n&&(this._responseCallbacks[e.id]=[n,i]),this._dispatcher.sendMessage(e,s,t||{}))},this)},_generateMessageId:function(){return this._messageId+=1,this._messageId>=Math.pow(2,32)&&(this._messageId=0),this._messageId.toString(36)},_receiveMessage:function(e){var t,n=e.id;void 0!==e.successful&&(t=this._responseCallbacks[n],delete this._responseCallbacks[n]),this.pipeThroughExtensions("incoming",e,null,function(e){e&&(e.advice&&this._handleAdvice(e.advice),this._deliverMessage(e),t&&t[0].call(t[1],e))},this)},_handleAdvice:function(e){Faye.extend(this._advice,e),this._dispatcher.timeout=this._advice.timeout/1e3,this._advice.reconnect===this.HANDSHAKE&&this._state!==this.DISCONNECTED&&(this._state=this.UNCONNECTED,this._dispatcher.clientId=null,this._cycleConnection())},_deliverMessage:function(e){e.channel&&void 0!==e.data&&(this.info("Client ? calling listeners for ? with ?",this._dispatcher.clientId,e.channel,e.data),this._channels.distributeMessage(e))},_cycleConnection:function(){this._connectRequest&&(this._connectRequest=null,this.info("Closed connection for ?",this._dispatcher.clientId));var e=this;Faye.ENV.setTimeout(function(){e.connect()},this._advice.interval)}}),Faye.extend(Faye.Client.prototype,Faye.Deferrable),Faye.extend(Faye.Client.prototype,Faye.Publisher),Faye.extend(Faye.Client.prototype,Faye.Logging),Faye.extend(Faye.Client.prototype,Faye.Extensible),Faye.Dispatcher=Faye.Class({MAX_REQUEST_SIZE:2048,DEFAULT_RETRY:5,UP:1,DOWN:2,initialize:function(e,t,n){this._client=e,this.endpoint=Faye.URI.parse(t),this._alternates=n.endpoints||{},this.cookies=Faye.Cookies&&new Faye.Cookies.CookieJar,this._disabled=[],this._envelopes={},this.headers={},this.retry=n.retry||this.DEFAULT_RETRY,this._scheduler=n.scheduler||Faye.Scheduler,this._state=0,this.transports={},this.wsExtensions=[],this.proxy=n.proxy||{},"string"==typeof this._proxy&&(this._proxy={origin:this._proxy});var i=n.websocketExtensions;if(i){i=[].concat(i);for(var s=0,r=i.length;s<r;s++)this.addWebsocketExtension(i[s])}this.tls=n.tls||{},this.tls.ca=this.tls.ca||n.ca;for(var o in this._alternates)this._alternates[o]=Faye.URI.parse(this._alternates[o]);this.maxRequestSize=this.MAX_REQUEST_SIZE},endpointFor:function(e){return this._alternates[e]||this.endpoint},addWebsocketExtension:function(e){this.wsExtensions.push(e)},disable:function(e){this._disabled.push(e)},setHeader:function(e,t){this.headers[e]=t},close:function(){var e=this._transport;delete this._transport,e&&e.close()},getConnectionTypes:function(){return Faye.Transport.getConnectionTypes()},selectTransport:function(e){Faye.Transport.get(this,e,this._disabled,function(e){this.debug("Selected ? transport for ?",e.connectionType,Faye.URI.stringify(e.endpoint)),e!==this._transport&&(this._transport&&this._transport.close(),this._transport=e,this.connectionType=e.connectionType)},this)},sendMessage:function(e,t,n){n=n||{};var i,s=e.id,r=n.attempts,o=n.deadline&&(new Date).getTime()+1e3*n.deadline,a=this._envelopes[s];a||(i=new this._scheduler(e,{timeout:t,interval:this.retry,attempts:r,deadline:o}),a=this._envelopes[s]={message:e,scheduler:i}),this._sendEnvelope(a)},_sendEnvelope:function(e){if(this._transport&&!e.request&&!e.timer){var t=e.message,n=e.scheduler,i=this;if(!n.isDeliverable())return n.abort(),void delete this._envelopes[t.id];e.timer=Faye.ENV.setTimeout(function(){i.handleError(t)},1e3*n.getTimeout()),n.send(),e.request=this._transport.sendMessage(t)}},handleResponse:function(e){var t=this._envelopes[e.id];void 0!==e.successful&&t&&(t.scheduler.succeed(),delete this._envelopes[e.id],Faye.ENV.clearTimeout(t.timer)),this.trigger("message",e),this._state!==this.UP&&(this._state=this.UP,this._client.trigger("transport:up"))},handleError:function(e,t){var n=this._envelopes[e.id],i=n&&n.request,s=this;if(i){i.then(function(e){e&&e.abort&&e.abort()});var r=n.scheduler;r.fail(),Faye.ENV.clearTimeout(n.timer),n.request=n.timer=null,t?this._sendEnvelope(n):n.timer=Faye.ENV.setTimeout(function(){n.timer=null,s._sendEnvelope(n)},1e3*r.getInterval()),this._state!==this.DOWN&&(this._state=this.DOWN,this._client.trigger("transport:down"))}}}),Faye.extend(Faye.Dispatcher.prototype,Faye.Publisher),Faye.extend(Faye.Dispatcher.prototype,Faye.Logging),Faye.Scheduler=function(e,t){this.message=e,this.options=t,this.attempts=0},Faye.extend(Faye.Scheduler.prototype,{getTimeout:function(){return this.options.timeout},getInterval:function(){return this.options.interval},isDeliverable:function(){var e=this.options.attempts,t=this.attempts,n=this.options.deadline,i=(new Date).getTime();return!(void 0!==e&&t>=e)&&!(void 0!==n&&i>n)},send:function(){this.attempts+=1},succeed:function(){},fail:function(){},abort:function(){}}),Faye.Transport=Faye.extend(Faye.Class({DEFAULT_PORTS:{"http:":80,"https:":443,"ws:":80,"wss:":443},SECURE_PROTOCOLS:["https:","wss:"],MAX_DELAY:0,batching:!0,initialize:function(e,t){this._dispatcher=e,this.endpoint=t,this._outbox=[],this._proxy=Faye.extend({},this._dispatcher.proxy),!this._proxy.origin&&Faye.NodeAdapter&&(this._proxy.origin=Faye.indexOf(this.SECURE_PROTOCOLS,this.endpoint.protocol)>=0?process.env.HTTPS_PROXY||process.env.https_proxy:process.env.HTTP_PROXY||process.env.http_proxy)},close:function(){},encode:function(e){return""},sendMessage:function(e){return this.debug("Client ? sending message to ?: ?",this._dispatcher.clientId,Faye.URI.stringify(this.endpoint),e),this.batching?(this._outbox.push(e),this._promise=this._promise||new Faye.Promise,this._flushLargeBatch(),e.channel===Faye.Channel.HANDSHAKE?(this.addTimeout("publish",.01,this._flush,this),this._promise):(e.channel===Faye.Channel.CONNECT&&(this._connectMessage=e),this.addTimeout("publish",this.MAX_DELAY,this._flush,this),this._promise)):Faye.Promise.fulfilled(this.request([e]))},_flush:function(){this.removeTimeout("publish"),this._outbox.length>1&&this._connectMessage&&(this._connectMessage.advice={timeout:0}),Faye.Promise.fulfill(this._promise,this.request(this._outbox)),delete this._promise,this._connectMessage=null,this._outbox=[]},_flushLargeBatch:function(){if(!(this.encode(this._outbox).length<this._dispatcher.maxRequestSize)){var e=this._outbox.pop();this._flush(),e&&this._outbox.push(e)}},_receive:function(e){if(e){e=[].concat(e),this.debug("Client ? received from ? via ?: ?",this._dispatcher.clientId,Faye.URI.stringify(this.endpoint),this.connectionType,e);for(var t=0,n=e.length;t<n;t++)this._dispatcher.handleResponse(e[t])}},_handleError:function(e,t){e=[].concat(e),this.debug("Client ? failed to send to ? via ?: ?",this._dispatcher.clientId,Faye.URI.stringify(this.endpoint),this.connectionType,e);for(var n=0,i=e.length;n<i;n++)this._dispatcher.handleError(e[n])},_getCookies:function(){var e=this._dispatcher.cookies,t=Faye.URI.stringify(this.endpoint);return e?Faye.map(e.getCookiesSync(t),function(e){return e.cookieString()}).join("; "):""},_storeCookies:function(e){var t,n=this._dispatcher.cookies,i=Faye.URI.stringify(this.endpoint);if(e&&n){e=[].concat(e);for(var s=0,r=e.length;s<r;s++)t=Faye.Cookies.Cookie.parse(e[s]),n.setCookieSync(t,i)}}}),{get:function(e,t,n,i,s){var r=e.endpoint;Faye.asyncEach(this._transports,function(r,o){var a=r[0],c=r[1],h=e.endpointFor(a);return Faye.indexOf(n,a)>=0?o():Faye.indexOf(t,a)<0?(c.isUsable(e,h,function(){}),o()):void c.isUsable(e,h,function(t){if(!t)return o();var n=c.hasOwnProperty("create")?c.create(e,h):new c(e,h);i.call(s,n)})},function(){throw Error("Could not find a usable connection type for "+Faye.URI.stringify(r))})},register:function(e,t){this._transports.push([e,t]),t.prototype.connectionType=e},getConnectionTypes:function(){return Faye.map(this._transports,function(e){return e[0]})},_transports:[]}),Faye.extend(Faye.Transport.prototype,Faye.Logging),Faye.extend(Faye.Transport.prototype,Faye.Timeouts),Faye.Event={_registry:[],on:function(e,t,n,i){var s=function(){n.call(i)};e.addEventListener?e.addEventListener(t,s,!1):e.attachEvent("on"+t,s),this._registry.push({_element:e,_type:t,_callback:n,_context:i,_handler:s})},detach:function(e,t,n,i){for(var s,r=this._registry.length;r--;)s=this._registry[r],e&&e!==s._element||t&&t!==s._type||n&&n!==s._callback||i&&i!==s._context||(s._element.removeEventListener?s._element.removeEventListener(s._type,s._handler,!1):s._element.detachEvent("on"+s._type,s._handler),this._registry.splice(r,1),s=null)}},void 0!==Faye.ENV.onunload&&Faye.Event.on(Faye.ENV,"unload",Faye.Event.detach,Faye.Event),"object"!=typeof JSON&&(JSON={}),function(){function f(e){return e<10?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,i,s,r,o,a=gap,c=t[e];switch(c&&"object"==typeof c&&"function"==typeof c.toJSON&&(c=c.toJSON(e)),"function"==typeof rep&&(c=rep.call(t,e,c)),typeof c){case"string":return quote(c);case"number":return isFinite(c)?c+"":"null";case"boolean":case"null":return c+"";case"object":if(!c)return"null";if(gap+=indent,o=[],"[object Array]"===Object.prototype.toString.apply(c)){for(r=c.length,n=0;n<r;n+=1)o[n]=str(n,c)||"null";return s=0===o.length?"[]":gap?"[\n"+gap+o.join(",\n"+gap)+"\n"+a+"]":"["+o.join(",")+"]",gap=a,s}if(rep&&"object"==typeof rep)for(r=rep.length,n=0;n<r;n+=1)"string"==typeof rep[n]&&(i=rep[n],(s=str(i,c))&&o.push(quote(i)+(gap?": ":":")+s));else for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(s=str(i,c))&&o.push(quote(i)+(gap?": ":":")+s);return s=0===o.length?"{}":gap?"{\n"+gap+o.join(",\n"+gap)+"\n"+a+"}":"{"+o.join(",")+"}",gap=a,s}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;Faye.stringify=function(e,t,n){var i;if(gap="",indent="","number"==typeof n)for(i=0;i<n;i+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw Error("JSON.stringify");return str("",{"":e})},"function"!=typeof JSON.stringify&&(JSON.stringify=Faye.stringify),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(e,t){var n,i,s=e[t];if(s&&"object"==typeof s)for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(i=walk(s,n),void 0!==i?s[n]=i:delete s[n]);return reviver.call(e,t,s)}var j;if(text+="",cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),Faye.Transport.WebSocket=Faye.extend(Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:!1,isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)}),this.connect()},request:function(e){this._pending=this._pending||new Faye.Set;for(var t=0,n=e.length;t<n;t++)this._pending.add(e[t]);var i=new Faye.Promise;return this.callback(function(t){t&&1===t.readyState&&(t.send(Faye.toJSON(e)),Faye.Promise.fulfill(i,t))},this),this.connect(),{abort:function(){i.then(function(e){e.close()})}}},connect:function(){if(!Faye.Transport.WebSocket._unloaded&&(this._state=this._state||this.UNCONNECTED,this._state===this.UNCONNECTED)){this._state=this.CONNECTING;var e=this._createSocket();if(!e)return this.setDeferredStatus("failed");var t=this;e.onopen=function(){e.headers&&t._storeCookies(e.headers["set-cookie"]),t._socket=e,t._state=t.CONNECTED,t._everConnected=!0,t._ping(),t.setDeferredStatus("succeeded",e)};var n=!1;e.onclose=e.onerror=function(){if(!n){n=!0;var i=t._state===t.CONNECTED;e.onopen=e.onclose=e.onerror=e.onmessage=null,delete t._socket,t._state=t.UNCONNECTED,t.removeTimeout("ping"),t.setDeferredStatus("unknown");var s=t._pending?t._pending.toArray():[];delete t._pending,i?t._handleError(s,!0):t._everConnected?t._handleError(s):t.setDeferredStatus("failed")}},e.onmessage=function(e){var n=JSON.parse(e.data);if(n){n=[].concat(n);for(var i=0,s=n.length;i<s;i++)void 0!==n[i].successful&&t._pending.remove(n[i]);t._receive(n)}}}},close:function(){this._socket&&this._socket.close()},_createSocket:function(){var e=Faye.Transport.WebSocket.getSocketUrl(this.endpoint),t=this._dispatcher.headers,n=this._dispatcher.wsExtensions,i=this._getCookies(),s=this._dispatcher.tls,r={extensions:n,headers:t,proxy:this._proxy,tls:s};return""!==i&&(r.headers.Cookie=i),Faye.WebSocket?new Faye.WebSocket.Client(e,[],r):Faye.ENV.MozWebSocket?new MozWebSocket(e):Faye.ENV.WebSocket?new WebSocket(e):void 0},_ping:function(){this._socket&&(this._socket.send("[]"),this.addTimeout("ping",this._dispatcher.timeout/2,this._ping,this))}}),{PROTOCOLS:{"http:":"ws:","https:":"wss:"},create:function(e,t){var n=e.transports.websocket=e.transports.websocket||{};return n[t.href]=n[t.href]||new this(e,t),n[t.href]},getSocketUrl:function(e){return e=Faye.copyObject(e),e.protocol=this.PROTOCOLS[e.protocol],Faye.URI.stringify(e)},isUsable:function(e,t,n,i){this.create(e,t).isUsable(n,i)}}),Faye.extend(Faye.Transport.WebSocket.prototype,Faye.Deferrable),Faye.Transport.register("websocket",Faye.Transport.WebSocket),Faye.Event&&void 0!==Faye.ENV.onbeforeunload&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.Transport.WebSocket._unloaded=!0}),Faye.Transport.EventSource=Faye.extend(Faye.Class(Faye.Transport,{initialize:function(e,t){if(Faye.Transport.prototype.initialize.call(this,e,t),!Faye.ENV.EventSource)return this.setDeferredStatus("failed");this._xhr=new Faye.Transport.XHR(e,t),t=Faye.copyObject(t),t.pathname+="/"+e.clientId;var n=new EventSource(Faye.URI.stringify(t)),i=this;n.onopen=function(){i._everConnected=!0,i.setDeferredStatus("succeeded")},n.onerror=function(){i._everConnected?i._handleError([]):(i.setDeferredStatus("failed"),n.close())},n.onmessage=function(e){i._receive(JSON.parse(e.data))},this._socket=n},close:function(){this._socket&&(this._socket.onopen=this._socket.onerror=this._socket.onmessage=null,this._socket.close(),delete this._socket)},isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)})},encode:function(e){return this._xhr.encode(e)},request:function(e){return this._xhr.request(e)}}),{isUsable:function(e,t,n,i){if(!e.clientId)return n.call(i,!1);Faye.Transport.XHR.isUsable(e,t,function(s){if(!s)return n.call(i,!1);this.create(e,t).isUsable(n,i)},this)},create:function(e,t){var n=e.transports.eventsource=e.transports.eventsource||{},i=e.clientId,s=Faye.copyObject(t);return s.pathname+="/"+(i||""),s=Faye.URI.stringify(s),n[s]=n[s]||new this(e,t),n[s]}}),Faye.extend(Faye.Transport.EventSource.prototype,Faye.Deferrable),Faye.Transport.register("eventsource",Faye.Transport.EventSource),Faye.Transport.XHR=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){return Faye.toJSON(e)},request:function(e){var t=this.endpoint.href,n=Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest,i=this;n.open("POST",t,!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Pragma","no-cache"),n.setRequestHeader("X-Requested-With","XMLHttpRequest");var s=this._dispatcher.headers;for(var r in s)s.hasOwnProperty(r)&&n.setRequestHeader(r,s[r]);var o=function(){n.abort()};return void 0!==Faye.ENV.onbeforeunload&&Faye.Event.on(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){if(n&&4===n.readyState){var t=null,s=n.status,r=n.responseText,a=s>=200&&s<300||304===s||1223===s;if(void 0!==Faye.ENV.onbeforeunload&&Faye.Event.detach(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){},n=null,!a)return i._handleError(e);try{t=JSON.parse(r)}catch(e){}t?i._receive(t):i._handleError(e)}},n.send(this.encode(e)),n}}),{isUsable:function(e,t,n,i){n.call(i,Faye.URI.isSameOrigin(t))}}),Faye.Transport.register("long-polling",Faye.Transport.XHR),Faye.Transport.CORS=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){return"message="+encodeURIComponent(Faye.toJSON(e))},request:function(e){var t,n=Faye.ENV.XDomainRequest?XDomainRequest:XMLHttpRequest,i=new n,s=++Faye.Transport.CORS._id,r=this._dispatcher.headers,o=this;if(i.open("POST",Faye.URI.stringify(this.endpoint),!0),i.setRequestHeader){i.setRequestHeader("Pragma","no-cache");for(t in r)r.hasOwnProperty(t)&&i.setRequestHeader(t,r[t])}var a=function(){if(!i)return!1;Faye.Transport.CORS._pending.remove(s),i.onload=i.onerror=i.ontimeout=i.onprogress=null,i=null};return i.onload=function(){var t=null;try{t=JSON.parse(i.responseText)}catch(e){}a(),t?o._receive(t):o._handleError(e)},i.onerror=i.ontimeout=function(){a(),o._handleError(e)},i.onprogress=function(){},n===Faye.ENV.XDomainRequest&&Faye.Transport.CORS._pending.add({id:s,xhr:i}),i.send(this.encode(e)),i}}),{_id:0,_pending:new Faye.Set,isUsable:function(e,t,n,i){if(Faye.URI.isSameOrigin(t))return n.call(i,!1);if(Faye.ENV.XDomainRequest)return n.call(i,t.protocol===Faye.ENV.location.protocol);if(Faye.ENV.XMLHttpRequest){var s=new Faye.ENV.XMLHttpRequest;return n.call(i,void 0!==s.withCredentials)}return n.call(i,!1)}}),Faye.Transport.register("cross-origin-long-polling",Faye.Transport.CORS),Faye.Transport.JSONP=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.copyObject(this.endpoint);return t.query.message=Faye.toJSON(e),t.query.jsonp="__jsonp"+Faye.Transport.JSONP._cbCount+"__",Faye.URI.stringify(t)},request:function(e){var t=document.getElementsByTagName("head")[0],n=document.createElement("script"),i=Faye.Transport.JSONP.getCallbackName(),s=Faye.copyObject(this.endpoint),r=this;s.query.message=Faye.toJSON(e),s.query.jsonp=i;var o=function(){if(!Faye.ENV[i])return!1;Faye.ENV[i]=void 0;try{delete Faye.ENV[i]}catch(e){}n.parentNode.removeChild(n)};return Faye.ENV[i]=function(e){o(),r._receive(e)},n.type="text/javascript",n.src=Faye.URI.stringify(s),t.appendChild(n),n.onerror=function(){o(),r._handleError(e)},{abort:o}}}),{_cbCount:0,getCallbackName:function(){return this._cbCount+=1,"__jsonp"+this._cbCount+"__"},isUsable:function(e,t,n,i){n.call(i,!0)}}),Faye.Transport.register("callback-polling",Faye.Transport.JSONP)}();
|
2
|
-
//# sourceMappingURL=faye-browser-min.js.map
|
data/lib/faye-browser-min.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["faye-browser.js"],"names":["Faye","VERSION","BAYEUX_VERSION","ID_LENGTH","JSONP_CALLBACK","CONNECTION_TYPES","MANDATORY_CONNECTION_TYPES","ENV","window","global","extend","dest","source","overwrite","key","hasOwnProperty","random","bitlength","this","maxLength","Math","ceil","log","string","csprng","length","validateOptions","options","validKeys","indexOf","Error","clientIdFromMessages","messages","connect","filter","concat","message","channel","clientId","copyObject","object","clone","i","Array","commonElement","lista","listb","n","list","needle","map","callback","context","result","push","call","array","asyncEach","iterator","calls","looping","iterate","resume","loop","toJSON","stringify","value","JSON","module","exports","Class","parent","methods","Object","klass","initialize","apply","arguments","bridge","prototype","xs","x","EventEmitter","isArray","toString","emit","type","_events","error","handler","args","slice","listeners","l","addListener","listener","on","once","self","g","removeListener","splice","removeAllListeners","Namespace","_used","exists","id","generate","name","release","defer","timeout","setTimeout","setImmediate","fn","process","nextTick","PENDING","FULFILLED","REJECTED","RETURN","THROW","Promise","task","_state","_onFulfilled","_onRejected","fulfill","reason","reject","then","onFulfilled","onRejected","next","registerOnFulfilled","registerOnRejected","promise","invoke","_value","_reason","_invoke","outcome","TypeError","resolve","called","_fulfill","v","r","shift","all","promises","fulfilled","deferred","pending","tuple","resolved","rejected","Set","_index","add","item","undefined","forEach","block","isEmpty","member","remove","removed","toArray","URI","isURI","uri","protocol","host","path","isSameOrigin","location","hostname","port","parse","url","parts","query","pairs","data","consume","pattern","replace","match","test","pathname","substr","split","search","decodeURIComponent","href","queryString","hash","encodeURIComponent","join","code","params","Grammar","ERROR","parseInt","versionMismatch","conntypeMismatch","extMismatch","badRequest","clientUnknown","parameterMissing","channelForbidden","channelUnknown","channelInvalid","extUnknown","publishFailed","serverError","Deferrable","errback","_promise","_reject","seconds","_timer","setDeferredStatus","status","clearTimeout","Publisher","countListeners","eventType","bind","_listeners","unbind","trigger","Timeouts","addTimeout","delay","_timeouts","removeTimeout","removeAllTimeouts","Logging","LOG_LEVELS","fatal","warn","info","debug","writeLog","messageArgs","level","logger","banner","className","e","CHANNEL_NAME","CHANNEL_PATTERN","Extensible","addExtension","extension","_extensions","added","removeExtension","pipeThroughExtensions","stage","request","extensions","pipe","Channel","isUnused","HANDSHAKE","CONNECT","SUBSCRIBE","UNSUBSCRIBE","DISCONNECT","META","SERVICE","expand","segments","channels","copy","unparse","isValid","isMeta","isService","isSubscribable","_channels","getKeys","keys","hasSubscription","subscribe","names","unsubscribe","distributeMessage","Publication","Subscription","client","_client","_callback","_context","_cancelled","cancel","Client","UNCONNECTED","CONNECTING","CONNECTED","DISCONNECTED","RETRY","NONE","CONNECTION_TIMEOUT","DEFAULT_ENDPOINT","INTERVAL","endpoint","_endpoint","_dispatcher","Dispatcher","_messageId","_responseCallbacks","_advice","reconnect","interval","_receiveMessage","Event","onbeforeunload","_disabled","disconnect","addWebsocketExtension","disable","feature","setHeader","handshake","selectTransport","_sendMessage","version","supportedConnectionTypes","getConnectionTypes","response","successful","retry","_connectRequest","connectionType","_cycleConnection","close","c","subscription","force","publish","publication","_generateMessageId","sendMessage","pow","advice","_handleAdvice","_deliverMessage","MAX_REQUEST_SIZE","DEFAULT_RETRY","UP","DOWN","_alternates","endpoints","cookies","Cookies","CookieJar","_envelopes","headers","_scheduler","scheduler","Scheduler","transports","wsExtensions","proxy","_proxy","origin","exts","websocketExtensions","tls","ca","maxRequestSize","endpointFor","transport","_transport","Transport","transportTypes","get","attempts","deadline","Date","getTime","envelope","_sendEnvelope","timer","isDeliverable","abort","handleError","getTimeout","send","handleResponse","reply","succeed","immediate","req","fail","getInterval","made","now","DEFAULT_PORTS","http:","https:","ws:","wss:","SECURE_PROTOCOLS","MAX_DELAY","batching","dispatcher","_outbox","NodeAdapter","env","HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","encode","_flushLargeBatch","_flush","_connectMessage","last","pop","_receive","replies","_handleError","_getCookies","getCookiesSync","cookie","cookieString","_storeCookies","setCookie","Cookie","setCookieSync","allowed","disabled","_transports","pair","connType","connEndpoint","isUsable","create","register","t","_registry","element","eventName","wrapped","addEventListener","attachEvent","_element","_type","_handler","detach","removeEventListener","detachEvent","onunload","f","quote","escapable","lastIndex","a","meta","charCodeAt","str","holder","k","partial","mind","gap","rep","isFinite","String","indent","valueOf","getUTCFullYear","getUTCMonth","getUTCDate","getUTCHours","getUTCMinutes","getUTCSeconds","Number","Boolean","cx","\b","\t","\n","\f","\r","\"","\\","replacer","space","","text","reviver","walk","j","eval","SyntaxError","WebSocket","_pending","socket","readyState","ws","_unloaded","_createSocket","onopen","_socket","_everConnected","_ping","closed","onclose","onerror","wasConnected","onmessage","event","getSocketUrl","MozWebSocket","PROTOCOLS","sockets","websocket","EventSource","_xhr","XHR","usable","eventsource","xhr","ActiveXObject","XMLHttpRequest","open","setRequestHeader","onreadystatechange","responseText","CORS","xhrClass","XDomainRequest","_id","cleanUp","onload","ontimeout","onprogress","withCredentials","JSONP","jsonp","_cbCount","head","document","getElementsByTagName","script","createElement","callbackName","getCallbackName","cleanup","parentNode","removeChild","src","appendChild"],"mappings":"CAAA,WACA,YAEA,IAAIA,OACFC,QAAkB,QAElBC,eAAkB,MAClBC,UAAkB,IAClBC,eAAkB,gBAClBC,kBAAmB,eAAgB,4BAA6B,mBAAoB,YAAa,cAAe,cAEhHC,4BAA6B,eAAgB,mBAAoB,cAEjEC,IAAwB,mBAAXC,QAA0BA,OAASC,OAEhDC,OAAQ,SAASC,EAAMC,EAAQC,GAC7B,IAAK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,MAAM2W,MAAU,UAAYjiB,KAAK0X,UAAUsK,MAAME,SAAW,KACzDliB,KAAKyK,IAAIxG,UAAUmH,IAG5BkF,QAAS,SAAStO,GAChB,GAAImgB,GAAeC,SAASC,qBAAqB,QAAQ,GACrDC,EAAeF,SAASG,cAAc,UACtCC,EAAexiB,KAAK0X,UAAUsK,MAAMS,kBACpCpP,EAAerT,KAAKuC,WAAWrB,KAAKmS,UACpCnN,EAAehF,IAEnBmS,GAAS/H,MAAMlJ,QAAUpC,KAAKgE,OAAOhC,GACrCqR,EAAS/H,MAAM2W,MAAUO,CAEzB,IAAIE,GAAU,WACZ,IAAK1iB,KAAKO,IAAIiiB,GAAe,OAAO,CACpCxiB,MAAKO,IAAIiiB,OAAgBvY,EACzB,WAAajK,MAAKO,IAAIiiB,GAAgB,MAAO7S,IAC7C2S,EAAOK,WAAWC,YAAYN,GAiBhC,OAdAtiB,MAAKO,IAAIiiB,GAAgB,SAAS/H,GAChCiI,IACAxc,EAAKsU,SAASC,IAGhB6H,EAAOhd,KAAO,kBACdgd,EAAOO,IAAO7iB,KAAKyK,IAAIxG,UAAUoP,GACjC8O,EAAKW,YAAYR,GAEjBA,EAAOpC,QAAU,WACfwC,IACAxc,EAAKwU,aAAa1Y,KAGZqW,MAAOqK,OAGjBR,SAAU,EAEVO,gBAAiB,WAEf,MADAvhB,MAAKghB,UAAY,EACV,UAAYhhB,KAAKghB,SAAW,MAGrCzG,SAAU,SAAS/B,EAAYrG,EAAUlQ,EAAUC,GACjDD,EAASI,KAAKH,GAAS,MAI3BpD,KAAK0X,UAAUiE,SAAS,mBAAoB3b,KAAK0X,UAAUsK","file":"faye-browser-min.js","sourceRoot":""}
|
data/lib/faye-browser.js
DELETED
@@ -1,2774 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
var Faye = {
|
5
|
-
VERSION: '1.1.3',
|
6
|
-
|
7
|
-
BAYEUX_VERSION: '1.0',
|
8
|
-
ID_LENGTH: 160,
|
9
|
-
JSONP_CALLBACK: 'jsonpcallback',
|
10
|
-
CONNECTION_TYPES: ['long-polling', 'cross-origin-long-polling', 'callback-polling', 'websocket', 'eventsource', 'in-process'],
|
11
|
-
|
12
|
-
MANDATORY_CONNECTION_TYPES: ['long-polling', 'callback-polling', 'in-process'],
|
13
|
-
|
14
|
-
ENV: (typeof window !== 'undefined') ? window : global,
|
15
|
-
|
16
|
-
extend: function(dest, source, overwrite) {
|
17
|
-
if (!source) return dest;
|
18
|
-
for (var key in source) {
|
19
|
-
if (!source.hasOwnProperty(key)) continue;
|
20
|
-
if (dest.hasOwnProperty(key) && overwrite === false) continue;
|
21
|
-
if (dest[key] !== source[key])
|
22
|
-
dest[key] = source[key];
|
23
|
-
}
|
24
|
-
return dest;
|
25
|
-
},
|
26
|
-
|
27
|
-
random: function(bitlength) {
|
28
|
-
bitlength = bitlength || this.ID_LENGTH;
|
29
|
-
var maxLength = Math.ceil(bitlength * Math.log(2) / Math.log(36));
|
30
|
-
var string = csprng(bitlength, 36);
|
31
|
-
while (string.length < maxLength) string = '0' + string;
|
32
|
-
return string;
|
33
|
-
},
|
34
|
-
|
35
|
-
validateOptions: function(options, validKeys) {
|
36
|
-
for (var key in options) {
|
37
|
-
if (this.indexOf(validKeys, key) < 0)
|
38
|
-
throw new Error('Unrecognized option: ' + key);
|
39
|
-
}
|
40
|
-
},
|
41
|
-
|
42
|
-
clientIdFromMessages: function(messages) {
|
43
|
-
var connect = this.filter([].concat(messages), function(message) {
|
44
|
-
return message.channel === '/meta/connect';
|
45
|
-
});
|
46
|
-
return connect[0] && connect[0].clientId;
|
47
|
-
},
|
48
|
-
|
49
|
-
copyObject: function(object) {
|
50
|
-
var clone, i, key;
|
51
|
-
if (object instanceof Array) {
|
52
|
-
clone = [];
|
53
|
-
i = object.length;
|
54
|
-
while (i--) clone[i] = Faye.copyObject(object[i]);
|
55
|
-
return clone;
|
56
|
-
} else if (typeof object === 'object') {
|
57
|
-
clone = (object === null) ? null : {};
|
58
|
-
for (key in object) clone[key] = Faye.copyObject(object[key]);
|
59
|
-
return clone;
|
60
|
-
} else {
|
61
|
-
return object;
|
62
|
-
}
|
63
|
-
},
|
64
|
-
|
65
|
-
commonElement: function(lista, listb) {
|
66
|
-
for (var i = 0, n = lista.length; i < n; i++) {
|
67
|
-
if (this.indexOf(listb, lista[i]) !== -1)
|
68
|
-
return lista[i];
|
69
|
-
}
|
70
|
-
return null;
|
71
|
-
},
|
72
|
-
|
73
|
-
indexOf: function(list, needle) {
|
74
|
-
if (list.indexOf) return list.indexOf(needle);
|
75
|
-
|
76
|
-
for (var i = 0, n = list.length; i < n; i++) {
|
77
|
-
if (list[i] === needle) return i;
|
78
|
-
}
|
79
|
-
return -1;
|
80
|
-
},
|
81
|
-
|
82
|
-
map: function(object, callback, context) {
|
83
|
-
if (object.map) return object.map(callback, context);
|
84
|
-
var result = [];
|
85
|
-
|
86
|
-
if (object instanceof Array) {
|
87
|
-
for (var i = 0, n = object.length; i < n; i++) {
|
88
|
-
result.push(callback.call(context || null, object[i], i));
|
89
|
-
}
|
90
|
-
} else {
|
91
|
-
for (var key in object) {
|
92
|
-
if (!object.hasOwnProperty(key)) continue;
|
93
|
-
result.push(callback.call(context || null, key, object[key]));
|
94
|
-
}
|
95
|
-
}
|
96
|
-
return result;
|
97
|
-
},
|
98
|
-
|
99
|
-
filter: function(array, callback, context) {
|
100
|
-
if (array.filter) return array.filter(callback, context);
|
101
|
-
var result = [];
|
102
|
-
for (var i = 0, n = array.length; i < n; i++) {
|
103
|
-
if (callback.call(context || null, array[i], i))
|
104
|
-
result.push(array[i]);
|
105
|
-
}
|
106
|
-
return result;
|
107
|
-
},
|
108
|
-
|
109
|
-
asyncEach: function(list, iterator, callback, context) {
|
110
|
-
var n = list.length,
|
111
|
-
i = -1,
|
112
|
-
calls = 0,
|
113
|
-
looping = false;
|
114
|
-
|
115
|
-
var iterate = function() {
|
116
|
-
calls -= 1;
|
117
|
-
i += 1;
|
118
|
-
if (i === n) return callback && callback.call(context);
|
119
|
-
iterator(list[i], resume);
|
120
|
-
};
|
121
|
-
|
122
|
-
var loop = function() {
|
123
|
-
if (looping) return;
|
124
|
-
looping = true;
|
125
|
-
while (calls > 0) iterate();
|
126
|
-
looping = false;
|
127
|
-
};
|
128
|
-
|
129
|
-
var resume = function() {
|
130
|
-
calls += 1;
|
131
|
-
loop();
|
132
|
-
};
|
133
|
-
resume();
|
134
|
-
},
|
135
|
-
|
136
|
-
// http://assanka.net/content/tech/2009/09/02/json2-js-vs-prototype/
|
137
|
-
toJSON: function(object) {
|
138
|
-
if (!this.stringify) return JSON.stringify(object);
|
139
|
-
|
140
|
-
return this.stringify(object, function(key, value) {
|
141
|
-
return (this[key] instanceof Array) ? this[key] : value;
|
142
|
-
});
|
143
|
-
}
|
144
|
-
};
|
145
|
-
|
146
|
-
if (typeof module !== 'undefined')
|
147
|
-
module.exports = Faye;
|
148
|
-
else if (typeof window !== 'undefined')
|
149
|
-
window.Faye = Faye;
|
150
|
-
|
151
|
-
Faye.Class = function(parent, methods) {
|
152
|
-
if (typeof parent !== 'function') {
|
153
|
-
methods = parent;
|
154
|
-
parent = Object;
|
155
|
-
}
|
156
|
-
|
157
|
-
var klass = function() {
|
158
|
-
if (!this.initialize) return this;
|
159
|
-
return this.initialize.apply(this, arguments) || this;
|
160
|
-
};
|
161
|
-
|
162
|
-
var bridge = function() {};
|
163
|
-
bridge.prototype = parent.prototype;
|
164
|
-
|
165
|
-
klass.prototype = new bridge();
|
166
|
-
Faye.extend(klass.prototype, methods);
|
167
|
-
|
168
|
-
return klass;
|
169
|
-
};
|
170
|
-
|
171
|
-
(function() {
|
172
|
-
var EventEmitter = Faye.EventEmitter = function() {};
|
173
|
-
|
174
|
-
/*
|
175
|
-
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
176
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
177
|
-
this software and associated documentation files (the "Software"), to deal in
|
178
|
-
the Software without restriction, including without limitation the rights to
|
179
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
180
|
-
of the Software, and to permit persons to whom the Software is furnished to do
|
181
|
-
so, subject to the following conditions:
|
182
|
-
|
183
|
-
The above copyright notice and this permission notice shall be included in all
|
184
|
-
copies or substantial portions of the Software.
|
185
|
-
|
186
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
187
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
188
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
189
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
190
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
191
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
192
|
-
SOFTWARE.
|
193
|
-
*/
|
194
|
-
|
195
|
-
var isArray = typeof Array.isArray === 'function'
|
196
|
-
? Array.isArray
|
197
|
-
: function (xs) {
|
198
|
-
return Object.prototype.toString.call(xs) === '[object Array]'
|
199
|
-
}
|
200
|
-
;
|
201
|
-
function indexOf (xs, x) {
|
202
|
-
if (xs.indexOf) return xs.indexOf(x);
|
203
|
-
for (var i = 0; i < xs.length; i++) {
|
204
|
-
if (x === xs[i]) return i;
|
205
|
-
}
|
206
|
-
return -1;
|
207
|
-
}
|
208
|
-
|
209
|
-
|
210
|
-
EventEmitter.prototype.emit = function(type) {
|
211
|
-
// If there is no 'error' event listener then throw.
|
212
|
-
if (type === 'error') {
|
213
|
-
if (!this._events || !this._events.error ||
|
214
|
-
(isArray(this._events.error) && !this._events.error.length))
|
215
|
-
{
|
216
|
-
if (arguments[1] instanceof Error) {
|
217
|
-
throw arguments[1]; // Unhandled 'error' event
|
218
|
-
} else {
|
219
|
-
throw new Error("Uncaught, unspecified 'error' event.");
|
220
|
-
}
|
221
|
-
return false;
|
222
|
-
}
|
223
|
-
}
|
224
|
-
|
225
|
-
if (!this._events) return false;
|
226
|
-
var handler = this._events[type];
|
227
|
-
if (!handler) return false;
|
228
|
-
|
229
|
-
if (typeof handler == 'function') {
|
230
|
-
switch (arguments.length) {
|
231
|
-
// fast cases
|
232
|
-
case 1:
|
233
|
-
handler.call(this);
|
234
|
-
break;
|
235
|
-
case 2:
|
236
|
-
handler.call(this, arguments[1]);
|
237
|
-
break;
|
238
|
-
case 3:
|
239
|
-
handler.call(this, arguments[1], arguments[2]);
|
240
|
-
break;
|
241
|
-
// slower
|
242
|
-
default:
|
243
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
244
|
-
handler.apply(this, args);
|
245
|
-
}
|
246
|
-
return true;
|
247
|
-
|
248
|
-
} else if (isArray(handler)) {
|
249
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
250
|
-
|
251
|
-
var listeners = handler.slice();
|
252
|
-
for (var i = 0, l = listeners.length; i < l; i++) {
|
253
|
-
listeners[i].apply(this, args);
|
254
|
-
}
|
255
|
-
return true;
|
256
|
-
|
257
|
-
} else {
|
258
|
-
return false;
|
259
|
-
}
|
260
|
-
};
|
261
|
-
|
262
|
-
// EventEmitter is defined in src/node_events.cc
|
263
|
-
// EventEmitter.prototype.emit() is also defined there.
|
264
|
-
EventEmitter.prototype.addListener = function(type, listener) {
|
265
|
-
if ('function' !== typeof listener) {
|
266
|
-
throw new Error('addListener only takes instances of Function');
|
267
|
-
}
|
268
|
-
|
269
|
-
if (!this._events) this._events = {};
|
270
|
-
|
271
|
-
// To avoid recursion in the case that type == "newListeners"! Before
|
272
|
-
// adding it to the listeners, first emit "newListeners".
|
273
|
-
this.emit('newListener', type, listener);
|
274
|
-
|
275
|
-
if (!this._events[type]) {
|
276
|
-
// Optimize the case of one listener. Don't need the extra array object.
|
277
|
-
this._events[type] = listener;
|
278
|
-
} else if (isArray(this._events[type])) {
|
279
|
-
// If we've already got an array, just append.
|
280
|
-
this._events[type].push(listener);
|
281
|
-
} else {
|
282
|
-
// Adding the second element, need to change to array.
|
283
|
-
this._events[type] = [this._events[type], listener];
|
284
|
-
}
|
285
|
-
|
286
|
-
return this;
|
287
|
-
};
|
288
|
-
|
289
|
-
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
290
|
-
|
291
|
-
EventEmitter.prototype.once = function(type, listener) {
|
292
|
-
var self = this;
|
293
|
-
self.on(type, function g() {
|
294
|
-
self.removeListener(type, g);
|
295
|
-
listener.apply(this, arguments);
|
296
|
-
});
|
297
|
-
|
298
|
-
return this;
|
299
|
-
};
|
300
|
-
|
301
|
-
EventEmitter.prototype.removeListener = function(type, listener) {
|
302
|
-
if ('function' !== typeof listener) {
|
303
|
-
throw new Error('removeListener only takes instances of Function');
|
304
|
-
}
|
305
|
-
|
306
|
-
// does not use listeners(), so no side effect of creating _events[type]
|
307
|
-
if (!this._events || !this._events[type]) return this;
|
308
|
-
|
309
|
-
var list = this._events[type];
|
310
|
-
|
311
|
-
if (isArray(list)) {
|
312
|
-
var i = indexOf(list, listener);
|
313
|
-
if (i < 0) return this;
|
314
|
-
list.splice(i, 1);
|
315
|
-
if (list.length == 0)
|
316
|
-
delete this._events[type];
|
317
|
-
} else if (this._events[type] === listener) {
|
318
|
-
delete this._events[type];
|
319
|
-
}
|
320
|
-
|
321
|
-
return this;
|
322
|
-
};
|
323
|
-
|
324
|
-
EventEmitter.prototype.removeAllListeners = function(type) {
|
325
|
-
if (arguments.length === 0) {
|
326
|
-
this._events = {};
|
327
|
-
return this;
|
328
|
-
}
|
329
|
-
|
330
|
-
// does not use listeners(), so no side effect of creating _events[type]
|
331
|
-
if (type && this._events && this._events[type]) this._events[type] = null;
|
332
|
-
return this;
|
333
|
-
};
|
334
|
-
|
335
|
-
EventEmitter.prototype.listeners = function(type) {
|
336
|
-
if (!this._events) this._events = {};
|
337
|
-
if (!this._events[type]) this._events[type] = [];
|
338
|
-
if (!isArray(this._events[type])) {
|
339
|
-
this._events[type] = [this._events[type]];
|
340
|
-
}
|
341
|
-
return this._events[type];
|
342
|
-
};
|
343
|
-
|
344
|
-
})();
|
345
|
-
|
346
|
-
Faye.Namespace = Faye.Class({
|
347
|
-
initialize: function() {
|
348
|
-
this._used = {};
|
349
|
-
},
|
350
|
-
|
351
|
-
exists: function(id) {
|
352
|
-
return this._used.hasOwnProperty(id);
|
353
|
-
},
|
354
|
-
|
355
|
-
generate: function() {
|
356
|
-
var name = Faye.random();
|
357
|
-
while (this._used.hasOwnProperty(name))
|
358
|
-
name = Faye.random();
|
359
|
-
return this._used[name] = name;
|
360
|
-
},
|
361
|
-
|
362
|
-
release: function(id) {
|
363
|
-
delete this._used[id];
|
364
|
-
}
|
365
|
-
});
|
366
|
-
|
367
|
-
(function() {
|
368
|
-
'use strict';
|
369
|
-
|
370
|
-
var timeout = setTimeout, defer;
|
371
|
-
|
372
|
-
if (typeof setImmediate === 'function')
|
373
|
-
defer = function(fn) { setImmediate(fn) };
|
374
|
-
else if (typeof process === 'object' && process.nextTick)
|
375
|
-
defer = function(fn) { process.nextTick(fn) };
|
376
|
-
else
|
377
|
-
defer = function(fn) { timeout(fn, 0) };
|
378
|
-
|
379
|
-
var PENDING = 0,
|
380
|
-
FULFILLED = 1,
|
381
|
-
REJECTED = 2;
|
382
|
-
|
383
|
-
var RETURN = function(x) { return x },
|
384
|
-
THROW = function(x) { throw x };
|
385
|
-
|
386
|
-
var Promise = function(task) {
|
387
|
-
this._state = PENDING;
|
388
|
-
this._onFulfilled = [];
|
389
|
-
this._onRejected = [];
|
390
|
-
|
391
|
-
if (typeof task !== 'function') return;
|
392
|
-
var self = this;
|
393
|
-
|
394
|
-
task(function(value) { fulfill(self, value) },
|
395
|
-
function(reason) { reject(self, reason) });
|
396
|
-
};
|
397
|
-
|
398
|
-
Promise.prototype.then = function(onFulfilled, onRejected) {
|
399
|
-
var next = new Promise();
|
400
|
-
registerOnFulfilled(this, onFulfilled, next);
|
401
|
-
registerOnRejected(this, onRejected, next);
|
402
|
-
return next;
|
403
|
-
};
|
404
|
-
|
405
|
-
var registerOnFulfilled = function(promise, onFulfilled, next) {
|
406
|
-
if (typeof onFulfilled !== 'function') onFulfilled = RETURN;
|
407
|
-
var handler = function(value) { invoke(onFulfilled, value, next) };
|
408
|
-
|
409
|
-
if (promise._state === PENDING) {
|
410
|
-
promise._onFulfilled.push(handler);
|
411
|
-
} else if (promise._state === FULFILLED) {
|
412
|
-
handler(promise._value);
|
413
|
-
}
|
414
|
-
};
|
415
|
-
|
416
|
-
var registerOnRejected = function(promise, onRejected, next) {
|
417
|
-
if (typeof onRejected !== 'function') onRejected = THROW;
|
418
|
-
var handler = function(reason) { invoke(onRejected, reason, next) };
|
419
|
-
|
420
|
-
if (promise._state === PENDING) {
|
421
|
-
promise._onRejected.push(handler);
|
422
|
-
} else if (promise._state === REJECTED) {
|
423
|
-
handler(promise._reason);
|
424
|
-
}
|
425
|
-
};
|
426
|
-
|
427
|
-
var invoke = function(fn, value, next) {
|
428
|
-
defer(function() { _invoke(fn, value, next) });
|
429
|
-
};
|
430
|
-
|
431
|
-
var _invoke = function(fn, value, next) {
|
432
|
-
var outcome;
|
433
|
-
|
434
|
-
try {
|
435
|
-
outcome = fn(value);
|
436
|
-
} catch (error) {
|
437
|
-
return reject(next, error);
|
438
|
-
}
|
439
|
-
|
440
|
-
if (outcome === next) {
|
441
|
-
reject(next, new TypeError('Recursive promise chain detected'));
|
442
|
-
} else {
|
443
|
-
fulfill(next, outcome);
|
444
|
-
}
|
445
|
-
};
|
446
|
-
|
447
|
-
var fulfill = Promise.fulfill = Promise.resolve = function(promise, value) {
|
448
|
-
var called = false, type, then;
|
449
|
-
|
450
|
-
try {
|
451
|
-
type = typeof value;
|
452
|
-
then = value !== null && (type === 'function' || type === 'object') && value.then;
|
453
|
-
|
454
|
-
if (typeof then !== 'function') return _fulfill(promise, value);
|
455
|
-
|
456
|
-
then.call(value, function(v) {
|
457
|
-
if (!(called ^ (called = true))) return;
|
458
|
-
fulfill(promise, v);
|
459
|
-
}, function(r) {
|
460
|
-
if (!(called ^ (called = true))) return;
|
461
|
-
reject(promise, r);
|
462
|
-
});
|
463
|
-
} catch (error) {
|
464
|
-
if (!(called ^ (called = true))) return;
|
465
|
-
reject(promise, error);
|
466
|
-
}
|
467
|
-
};
|
468
|
-
|
469
|
-
var _fulfill = function(promise, value) {
|
470
|
-
if (promise._state !== PENDING) return;
|
471
|
-
|
472
|
-
promise._state = FULFILLED;
|
473
|
-
promise._value = value;
|
474
|
-
promise._onRejected = [];
|
475
|
-
|
476
|
-
var onFulfilled = promise._onFulfilled, fn;
|
477
|
-
while (fn = onFulfilled.shift()) fn(value);
|
478
|
-
};
|
479
|
-
|
480
|
-
var reject = Promise.reject = function(promise, reason) {
|
481
|
-
if (promise._state !== PENDING) return;
|
482
|
-
|
483
|
-
promise._state = REJECTED;
|
484
|
-
promise._reason = reason;
|
485
|
-
promise._onFulfilled = [];
|
486
|
-
|
487
|
-
var onRejected = promise._onRejected, fn;
|
488
|
-
while (fn = onRejected.shift()) fn(reason);
|
489
|
-
};
|
490
|
-
|
491
|
-
Promise.all = function(promises) {
|
492
|
-
return new Promise(function(fulfill, reject) {
|
493
|
-
var list = [],
|
494
|
-
n = promises.length,
|
495
|
-
i;
|
496
|
-
|
497
|
-
if (n === 0) return fulfill(list);
|
498
|
-
|
499
|
-
for (i = 0; i < n; i++) (function(promise, i) {
|
500
|
-
Promise.fulfilled(promise).then(function(value) {
|
501
|
-
list[i] = value;
|
502
|
-
if (--n === 0) fulfill(list);
|
503
|
-
}, reject);
|
504
|
-
})(promises[i], i);
|
505
|
-
});
|
506
|
-
};
|
507
|
-
|
508
|
-
Promise.defer = defer;
|
509
|
-
|
510
|
-
Promise.deferred = Promise.pending = function() {
|
511
|
-
var tuple = {};
|
512
|
-
|
513
|
-
tuple.promise = new Promise(function(fulfill, reject) {
|
514
|
-
tuple.fulfill = tuple.resolve = fulfill;
|
515
|
-
tuple.reject = reject;
|
516
|
-
});
|
517
|
-
return tuple;
|
518
|
-
};
|
519
|
-
|
520
|
-
Promise.fulfilled = Promise.resolved = function(value) {
|
521
|
-
return new Promise(function(fulfill, reject) { fulfill(value) });
|
522
|
-
};
|
523
|
-
|
524
|
-
Promise.rejected = function(reason) {
|
525
|
-
return new Promise(function(fulfill, reject) { reject(reason) });
|
526
|
-
};
|
527
|
-
|
528
|
-
if (typeof Faye === 'undefined')
|
529
|
-
module.exports = Promise;
|
530
|
-
else
|
531
|
-
Faye.Promise = Promise;
|
532
|
-
|
533
|
-
})();
|
534
|
-
|
535
|
-
Faye.Set = Faye.Class({
|
536
|
-
initialize: function() {
|
537
|
-
this._index = {};
|
538
|
-
},
|
539
|
-
|
540
|
-
add: function(item) {
|
541
|
-
var key = (item.id !== undefined) ? item.id : item;
|
542
|
-
if (this._index.hasOwnProperty(key)) return false;
|
543
|
-
this._index[key] = item;
|
544
|
-
return true;
|
545
|
-
},
|
546
|
-
|
547
|
-
forEach: function(block, context) {
|
548
|
-
for (var key in this._index) {
|
549
|
-
if (this._index.hasOwnProperty(key))
|
550
|
-
block.call(context, this._index[key]);
|
551
|
-
}
|
552
|
-
},
|
553
|
-
|
554
|
-
isEmpty: function() {
|
555
|
-
for (var key in this._index) {
|
556
|
-
if (this._index.hasOwnProperty(key)) return false;
|
557
|
-
}
|
558
|
-
return true;
|
559
|
-
},
|
560
|
-
|
561
|
-
member: function(item) {
|
562
|
-
for (var key in this._index) {
|
563
|
-
if (this._index[key] === item) return true;
|
564
|
-
}
|
565
|
-
return false;
|
566
|
-
},
|
567
|
-
|
568
|
-
remove: function(item) {
|
569
|
-
var key = (item.id !== undefined) ? item.id : item;
|
570
|
-
var removed = this._index[key];
|
571
|
-
delete this._index[key];
|
572
|
-
return removed;
|
573
|
-
},
|
574
|
-
|
575
|
-
toArray: function() {
|
576
|
-
var array = [];
|
577
|
-
this.forEach(function(item) { array.push(item) });
|
578
|
-
return array;
|
579
|
-
}
|
580
|
-
});
|
581
|
-
|
582
|
-
Faye.URI = {
|
583
|
-
isURI: function(uri) {
|
584
|
-
return uri && uri.protocol && uri.host && uri.path;
|
585
|
-
},
|
586
|
-
|
587
|
-
isSameOrigin: function(uri) {
|
588
|
-
var location = Faye.ENV.location;
|
589
|
-
return uri.protocol === location.protocol &&
|
590
|
-
uri.hostname === location.hostname &&
|
591
|
-
uri.port === location.port;
|
592
|
-
},
|
593
|
-
|
594
|
-
parse: function(url) {
|
595
|
-
if (typeof url !== 'string') return url;
|
596
|
-
var uri = {}, parts, query, pairs, i, n, data;
|
597
|
-
|
598
|
-
var consume = function(name, pattern) {
|
599
|
-
url = url.replace(pattern, function(match) {
|
600
|
-
uri[name] = match;
|
601
|
-
return '';
|
602
|
-
});
|
603
|
-
uri[name] = uri[name] || '';
|
604
|
-
};
|
605
|
-
|
606
|
-
consume('protocol', /^[a-z]+\:/i);
|
607
|
-
consume('host', /^\/\/[^\/\?#]+/);
|
608
|
-
|
609
|
-
if (!/^\//.test(url) && !uri.host)
|
610
|
-
url = Faye.ENV.location.pathname.replace(/[^\/]*$/, '') + url;
|
611
|
-
|
612
|
-
consume('pathname', /^[^\?#]*/);
|
613
|
-
consume('search', /^\?[^#]*/);
|
614
|
-
consume('hash', /^#.*/);
|
615
|
-
|
616
|
-
uri.protocol = uri.protocol || Faye.ENV.location.protocol;
|
617
|
-
|
618
|
-
if (uri.host) {
|
619
|
-
uri.host = uri.host.substr(2);
|
620
|
-
parts = uri.host.split(':');
|
621
|
-
uri.hostname = parts[0];
|
622
|
-
uri.port = parts[1] || '';
|
623
|
-
} else {
|
624
|
-
uri.host = Faye.ENV.location.host;
|
625
|
-
uri.hostname = Faye.ENV.location.hostname;
|
626
|
-
uri.port = Faye.ENV.location.port;
|
627
|
-
}
|
628
|
-
|
629
|
-
uri.pathname = uri.pathname || '/';
|
630
|
-
uri.path = uri.pathname + uri.search;
|
631
|
-
|
632
|
-
query = uri.search.replace(/^\?/, '');
|
633
|
-
pairs = query ? query.split('&') : [];
|
634
|
-
data = {};
|
635
|
-
|
636
|
-
for (i = 0, n = pairs.length; i < n; i++) {
|
637
|
-
parts = pairs[i].split('=');
|
638
|
-
data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');
|
639
|
-
}
|
640
|
-
|
641
|
-
uri.query = data;
|
642
|
-
|
643
|
-
uri.href = this.stringify(uri);
|
644
|
-
return uri;
|
645
|
-
},
|
646
|
-
|
647
|
-
stringify: function(uri) {
|
648
|
-
var string = uri.protocol + '//' + uri.hostname;
|
649
|
-
if (uri.port) string += ':' + uri.port;
|
650
|
-
string += uri.pathname + this.queryString(uri.query) + (uri.hash || '');
|
651
|
-
return string;
|
652
|
-
},
|
653
|
-
|
654
|
-
queryString: function(query) {
|
655
|
-
var pairs = [];
|
656
|
-
for (var key in query) {
|
657
|
-
if (!query.hasOwnProperty(key)) continue;
|
658
|
-
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(query[key]));
|
659
|
-
}
|
660
|
-
if (pairs.length === 0) return '';
|
661
|
-
return '?' + pairs.join('&');
|
662
|
-
}
|
663
|
-
};
|
664
|
-
|
665
|
-
Faye.Error = Faye.Class({
|
666
|
-
initialize: function(code, params, message) {
|
667
|
-
this.code = code;
|
668
|
-
this.params = Array.prototype.slice.call(params);
|
669
|
-
this.message = message;
|
670
|
-
},
|
671
|
-
|
672
|
-
toString: function() {
|
673
|
-
return this.code + ':' +
|
674
|
-
this.params.join(',') + ':' +
|
675
|
-
this.message;
|
676
|
-
}
|
677
|
-
});
|
678
|
-
|
679
|
-
Faye.Error.parse = function(message) {
|
680
|
-
message = message || '';
|
681
|
-
if (!Faye.Grammar.ERROR.test(message)) return new this(null, [], message);
|
682
|
-
|
683
|
-
var parts = message.split(':'),
|
684
|
-
code = parseInt(parts[0]),
|
685
|
-
params = parts[1].split(','),
|
686
|
-
message = parts[2];
|
687
|
-
|
688
|
-
return new this(code, params, message);
|
689
|
-
};
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
Faye.Error.versionMismatch = function() {
|
695
|
-
return new this(300, arguments, 'Version mismatch').toString();
|
696
|
-
};
|
697
|
-
|
698
|
-
Faye.Error.conntypeMismatch = function() {
|
699
|
-
return new this(301, arguments, 'Connection types not supported').toString();
|
700
|
-
};
|
701
|
-
|
702
|
-
Faye.Error.extMismatch = function() {
|
703
|
-
return new this(302, arguments, 'Extension mismatch').toString();
|
704
|
-
};
|
705
|
-
|
706
|
-
Faye.Error.badRequest = function() {
|
707
|
-
return new this(400, arguments, 'Bad request').toString();
|
708
|
-
};
|
709
|
-
|
710
|
-
Faye.Error.clientUnknown = function() {
|
711
|
-
return new this(401, arguments, 'Unknown client').toString();
|
712
|
-
};
|
713
|
-
|
714
|
-
Faye.Error.parameterMissing = function() {
|
715
|
-
return new this(402, arguments, 'Missing required parameter').toString();
|
716
|
-
};
|
717
|
-
|
718
|
-
Faye.Error.channelForbidden = function() {
|
719
|
-
return new this(403, arguments, 'Forbidden channel').toString();
|
720
|
-
};
|
721
|
-
|
722
|
-
Faye.Error.channelUnknown = function() {
|
723
|
-
return new this(404, arguments, 'Unknown channel').toString();
|
724
|
-
};
|
725
|
-
|
726
|
-
Faye.Error.channelInvalid = function() {
|
727
|
-
return new this(405, arguments, 'Invalid channel').toString();
|
728
|
-
};
|
729
|
-
|
730
|
-
Faye.Error.extUnknown = function() {
|
731
|
-
return new this(406, arguments, 'Unknown extension').toString();
|
732
|
-
};
|
733
|
-
|
734
|
-
Faye.Error.publishFailed = function() {
|
735
|
-
return new this(407, arguments, 'Failed to publish').toString();
|
736
|
-
};
|
737
|
-
|
738
|
-
Faye.Error.serverError = function() {
|
739
|
-
return new this(500, arguments, 'Internal server error').toString();
|
740
|
-
};
|
741
|
-
|
742
|
-
|
743
|
-
Faye.Deferrable = {
|
744
|
-
then: function(callback, errback) {
|
745
|
-
var self = this;
|
746
|
-
if (!this._promise)
|
747
|
-
this._promise = new Faye.Promise(function(fulfill, reject) {
|
748
|
-
self._fulfill = fulfill;
|
749
|
-
self._reject = reject;
|
750
|
-
});
|
751
|
-
|
752
|
-
if (arguments.length === 0)
|
753
|
-
return this._promise;
|
754
|
-
else
|
755
|
-
return this._promise.then(callback, errback);
|
756
|
-
},
|
757
|
-
|
758
|
-
callback: function(callback, context) {
|
759
|
-
return this.then(function(value) { callback.call(context, value) });
|
760
|
-
},
|
761
|
-
|
762
|
-
errback: function(callback, context) {
|
763
|
-
return this.then(null, function(reason) { callback.call(context, reason) });
|
764
|
-
},
|
765
|
-
|
766
|
-
timeout: function(seconds, message) {
|
767
|
-
this.then();
|
768
|
-
var self = this;
|
769
|
-
this._timer = Faye.ENV.setTimeout(function() {
|
770
|
-
self._reject(message);
|
771
|
-
}, seconds * 1000);
|
772
|
-
},
|
773
|
-
|
774
|
-
setDeferredStatus: function(status, value) {
|
775
|
-
if (this._timer) Faye.ENV.clearTimeout(this._timer);
|
776
|
-
|
777
|
-
this.then();
|
778
|
-
|
779
|
-
if (status === 'succeeded')
|
780
|
-
this._fulfill(value);
|
781
|
-
else if (status === 'failed')
|
782
|
-
this._reject(value);
|
783
|
-
else
|
784
|
-
delete this._promise;
|
785
|
-
}
|
786
|
-
};
|
787
|
-
|
788
|
-
Faye.Publisher = {
|
789
|
-
countListeners: function(eventType) {
|
790
|
-
return this.listeners(eventType).length;
|
791
|
-
},
|
792
|
-
|
793
|
-
bind: function(eventType, listener, context) {
|
794
|
-
var slice = Array.prototype.slice,
|
795
|
-
handler = function() { listener.apply(context, slice.call(arguments)) };
|
796
|
-
|
797
|
-
this._listeners = this._listeners || [];
|
798
|
-
this._listeners.push([eventType, listener, context, handler]);
|
799
|
-
return this.on(eventType, handler);
|
800
|
-
},
|
801
|
-
|
802
|
-
unbind: function(eventType, listener, context) {
|
803
|
-
this._listeners = this._listeners || [];
|
804
|
-
var n = this._listeners.length, tuple;
|
805
|
-
|
806
|
-
while (n--) {
|
807
|
-
tuple = this._listeners[n];
|
808
|
-
if (tuple[0] !== eventType) continue;
|
809
|
-
if (listener && (tuple[1] !== listener || tuple[2] !== context)) continue;
|
810
|
-
this._listeners.splice(n, 1);
|
811
|
-
this.removeListener(eventType, tuple[3]);
|
812
|
-
}
|
813
|
-
}
|
814
|
-
};
|
815
|
-
|
816
|
-
Faye.extend(Faye.Publisher, Faye.EventEmitter.prototype);
|
817
|
-
Faye.Publisher.trigger = Faye.Publisher.emit;
|
818
|
-
|
819
|
-
Faye.Timeouts = {
|
820
|
-
addTimeout: function(name, delay, callback, context) {
|
821
|
-
this._timeouts = this._timeouts || {};
|
822
|
-
if (this._timeouts.hasOwnProperty(name)) return;
|
823
|
-
var self = this;
|
824
|
-
this._timeouts[name] = Faye.ENV.setTimeout(function() {
|
825
|
-
delete self._timeouts[name];
|
826
|
-
callback.call(context);
|
827
|
-
}, 1000 * delay);
|
828
|
-
},
|
829
|
-
|
830
|
-
removeTimeout: function(name) {
|
831
|
-
this._timeouts = this._timeouts || {};
|
832
|
-
var timeout = this._timeouts[name];
|
833
|
-
if (!timeout) return;
|
834
|
-
Faye.ENV.clearTimeout(timeout);
|
835
|
-
delete this._timeouts[name];
|
836
|
-
},
|
837
|
-
|
838
|
-
removeAllTimeouts: function() {
|
839
|
-
this._timeouts = this._timeouts || {};
|
840
|
-
for (var name in this._timeouts) this.removeTimeout(name);
|
841
|
-
}
|
842
|
-
};
|
843
|
-
|
844
|
-
Faye.Logging = {
|
845
|
-
LOG_LEVELS: {
|
846
|
-
fatal: 4,
|
847
|
-
error: 3,
|
848
|
-
warn: 2,
|
849
|
-
info: 1,
|
850
|
-
debug: 0
|
851
|
-
},
|
852
|
-
|
853
|
-
writeLog: function(messageArgs, level) {
|
854
|
-
if (!Faye.logger) return;
|
855
|
-
|
856
|
-
var args = Array.prototype.slice.apply(messageArgs),
|
857
|
-
banner = '[Faye',
|
858
|
-
klass = this.className,
|
859
|
-
|
860
|
-
message = args.shift().replace(/\?/g, function() {
|
861
|
-
try {
|
862
|
-
return Faye.toJSON(args.shift());
|
863
|
-
} catch (e) {
|
864
|
-
return '[Object]';
|
865
|
-
}
|
866
|
-
});
|
867
|
-
|
868
|
-
for (var key in Faye) {
|
869
|
-
if (klass) continue;
|
870
|
-
if (typeof Faye[key] !== 'function') continue;
|
871
|
-
if (this instanceof Faye[key]) klass = key;
|
872
|
-
}
|
873
|
-
if (klass) banner += '.' + klass;
|
874
|
-
banner += '] ';
|
875
|
-
|
876
|
-
if (typeof Faye.logger[level] === 'function')
|
877
|
-
Faye.logger[level](banner + message);
|
878
|
-
else if (typeof Faye.logger === 'function')
|
879
|
-
Faye.logger(banner + message);
|
880
|
-
}
|
881
|
-
};
|
882
|
-
|
883
|
-
(function() {
|
884
|
-
for (var key in Faye.Logging.LOG_LEVELS)
|
885
|
-
(function(level) {
|
886
|
-
Faye.Logging[level] = function() {
|
887
|
-
this.writeLog(arguments, level);
|
888
|
-
};
|
889
|
-
})(key);
|
890
|
-
})();
|
891
|
-
|
892
|
-
Faye.Grammar = {
|
893
|
-
CHANNEL_NAME: /^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,
|
894
|
-
CHANNEL_PATTERN: /^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,
|
895
|
-
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])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/,
|
896
|
-
VERSION: /^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/
|
897
|
-
};
|
898
|
-
|
899
|
-
Faye.Extensible = {
|
900
|
-
addExtension: function(extension) {
|
901
|
-
this._extensions = this._extensions || [];
|
902
|
-
this._extensions.push(extension);
|
903
|
-
if (extension.added) extension.added(this);
|
904
|
-
},
|
905
|
-
|
906
|
-
removeExtension: function(extension) {
|
907
|
-
if (!this._extensions) return;
|
908
|
-
var i = this._extensions.length;
|
909
|
-
while (i--) {
|
910
|
-
if (this._extensions[i] !== extension) continue;
|
911
|
-
this._extensions.splice(i,1);
|
912
|
-
if (extension.removed) extension.removed(this);
|
913
|
-
}
|
914
|
-
},
|
915
|
-
|
916
|
-
pipeThroughExtensions: function(stage, message, request, callback, context) {
|
917
|
-
this.debug('Passing through ? extensions: ?', stage, message);
|
918
|
-
|
919
|
-
if (!this._extensions) return callback.call(context, message);
|
920
|
-
var extensions = this._extensions.slice();
|
921
|
-
|
922
|
-
var pipe = function(message) {
|
923
|
-
if (!message) return callback.call(context, message);
|
924
|
-
|
925
|
-
var extension = extensions.shift();
|
926
|
-
if (!extension) return callback.call(context, message);
|
927
|
-
|
928
|
-
var fn = extension[stage];
|
929
|
-
if (!fn) return pipe(message);
|
930
|
-
|
931
|
-
if (fn.length >= 3) extension[stage](message, request, pipe);
|
932
|
-
else extension[stage](message, pipe);
|
933
|
-
};
|
934
|
-
pipe(message);
|
935
|
-
}
|
936
|
-
};
|
937
|
-
|
938
|
-
Faye.extend(Faye.Extensible, Faye.Logging);
|
939
|
-
|
940
|
-
Faye.Channel = Faye.Class({
|
941
|
-
initialize: function(name) {
|
942
|
-
this.id = this.name = name;
|
943
|
-
},
|
944
|
-
|
945
|
-
push: function(message) {
|
946
|
-
this.trigger('message', message);
|
947
|
-
},
|
948
|
-
|
949
|
-
isUnused: function() {
|
950
|
-
return this.countListeners('message') === 0;
|
951
|
-
}
|
952
|
-
});
|
953
|
-
|
954
|
-
Faye.extend(Faye.Channel.prototype, Faye.Publisher);
|
955
|
-
|
956
|
-
Faye.extend(Faye.Channel, {
|
957
|
-
HANDSHAKE: '/meta/handshake',
|
958
|
-
CONNECT: '/meta/connect',
|
959
|
-
SUBSCRIBE: '/meta/subscribe',
|
960
|
-
UNSUBSCRIBE: '/meta/unsubscribe',
|
961
|
-
DISCONNECT: '/meta/disconnect',
|
962
|
-
|
963
|
-
META: 'meta',
|
964
|
-
SERVICE: 'service',
|
965
|
-
|
966
|
-
expand: function(name) {
|
967
|
-
var segments = this.parse(name),
|
968
|
-
channels = ['/**', name];
|
969
|
-
|
970
|
-
var copy = segments.slice();
|
971
|
-
copy[copy.length - 1] = '*';
|
972
|
-
channels.push(this.unparse(copy));
|
973
|
-
|
974
|
-
for (var i = 1, n = segments.length; i < n; i++) {
|
975
|
-
copy = segments.slice(0, i);
|
976
|
-
copy.push('**');
|
977
|
-
channels.push(this.unparse(copy));
|
978
|
-
}
|
979
|
-
|
980
|
-
return channels;
|
981
|
-
},
|
982
|
-
|
983
|
-
isValid: function(name) {
|
984
|
-
return Faye.Grammar.CHANNEL_NAME.test(name) ||
|
985
|
-
Faye.Grammar.CHANNEL_PATTERN.test(name);
|
986
|
-
},
|
987
|
-
|
988
|
-
parse: function(name) {
|
989
|
-
if (!this.isValid(name)) return null;
|
990
|
-
return name.split('/').slice(1);
|
991
|
-
},
|
992
|
-
|
993
|
-
unparse: function(segments) {
|
994
|
-
return '/' + segments.join('/');
|
995
|
-
},
|
996
|
-
|
997
|
-
isMeta: function(name) {
|
998
|
-
var segments = this.parse(name);
|
999
|
-
return segments ? (segments[0] === this.META) : null;
|
1000
|
-
},
|
1001
|
-
|
1002
|
-
isService: function(name) {
|
1003
|
-
var segments = this.parse(name);
|
1004
|
-
return segments ? (segments[0] === this.SERVICE) : null;
|
1005
|
-
},
|
1006
|
-
|
1007
|
-
isSubscribable: function(name) {
|
1008
|
-
if (!this.isValid(name)) return null;
|
1009
|
-
return !this.isMeta(name) && !this.isService(name);
|
1010
|
-
},
|
1011
|
-
|
1012
|
-
Set: Faye.Class({
|
1013
|
-
initialize: function() {
|
1014
|
-
this._channels = {};
|
1015
|
-
},
|
1016
|
-
|
1017
|
-
getKeys: function() {
|
1018
|
-
var keys = [];
|
1019
|
-
for (var key in this._channels) keys.push(key);
|
1020
|
-
return keys;
|
1021
|
-
},
|
1022
|
-
|
1023
|
-
remove: function(name) {
|
1024
|
-
delete this._channels[name];
|
1025
|
-
},
|
1026
|
-
|
1027
|
-
hasSubscription: function(name) {
|
1028
|
-
return this._channels.hasOwnProperty(name);
|
1029
|
-
},
|
1030
|
-
|
1031
|
-
subscribe: function(names, callback, context) {
|
1032
|
-
var name;
|
1033
|
-
for (var i = 0, n = names.length; i < n; i++) {
|
1034
|
-
name = names[i];
|
1035
|
-
var channel = this._channels[name] = this._channels[name] || new Faye.Channel(name);
|
1036
|
-
if (callback) channel.bind('message', callback, context);
|
1037
|
-
}
|
1038
|
-
},
|
1039
|
-
|
1040
|
-
unsubscribe: function(name, callback, context) {
|
1041
|
-
var channel = this._channels[name];
|
1042
|
-
if (!channel) return false;
|
1043
|
-
channel.unbind('message', callback, context);
|
1044
|
-
|
1045
|
-
if (channel.isUnused()) {
|
1046
|
-
this.remove(name);
|
1047
|
-
return true;
|
1048
|
-
} else {
|
1049
|
-
return false;
|
1050
|
-
}
|
1051
|
-
},
|
1052
|
-
|
1053
|
-
distributeMessage: function(message) {
|
1054
|
-
var channels = Faye.Channel.expand(message.channel);
|
1055
|
-
|
1056
|
-
for (var i = 0, n = channels.length; i < n; i++) {
|
1057
|
-
var channel = this._channels[channels[i]];
|
1058
|
-
if (channel) channel.trigger('message', message.data);
|
1059
|
-
}
|
1060
|
-
}
|
1061
|
-
})
|
1062
|
-
});
|
1063
|
-
|
1064
|
-
Faye.Publication = Faye.Class(Faye.Deferrable);
|
1065
|
-
|
1066
|
-
Faye.Subscription = Faye.Class({
|
1067
|
-
initialize: function(client, channels, callback, context) {
|
1068
|
-
this._client = client;
|
1069
|
-
this._channels = channels;
|
1070
|
-
this._callback = callback;
|
1071
|
-
this._context = context;
|
1072
|
-
this._cancelled = false;
|
1073
|
-
},
|
1074
|
-
|
1075
|
-
cancel: function() {
|
1076
|
-
if (this._cancelled) return;
|
1077
|
-
this._client.unsubscribe(this._channels, this._callback, this._context);
|
1078
|
-
this._cancelled = true;
|
1079
|
-
},
|
1080
|
-
|
1081
|
-
unsubscribe: function() {
|
1082
|
-
this.cancel();
|
1083
|
-
}
|
1084
|
-
});
|
1085
|
-
|
1086
|
-
Faye.extend(Faye.Subscription.prototype, Faye.Deferrable);
|
1087
|
-
|
1088
|
-
Faye.Client = Faye.Class({
|
1089
|
-
UNCONNECTED: 1,
|
1090
|
-
CONNECTING: 2,
|
1091
|
-
CONNECTED: 3,
|
1092
|
-
DISCONNECTED: 4,
|
1093
|
-
|
1094
|
-
HANDSHAKE: 'handshake',
|
1095
|
-
RETRY: 'retry',
|
1096
|
-
NONE: 'none',
|
1097
|
-
|
1098
|
-
CONNECTION_TIMEOUT: 60,
|
1099
|
-
|
1100
|
-
DEFAULT_ENDPOINT: '/bayeux',
|
1101
|
-
INTERVAL: 0,
|
1102
|
-
|
1103
|
-
initialize: function(endpoint, options) {
|
1104
|
-
this.info('New client created for ?', endpoint);
|
1105
|
-
options = options || {};
|
1106
|
-
|
1107
|
-
Faye.validateOptions(options, ['interval', 'timeout', 'endpoints', 'proxy', 'retry', 'scheduler', 'websocketExtensions', 'tls', 'ca']);
|
1108
|
-
|
1109
|
-
this._endpoint = endpoint || this.DEFAULT_ENDPOINT;
|
1110
|
-
this._channels = new Faye.Channel.Set();
|
1111
|
-
this._dispatcher = new Faye.Dispatcher(this, this._endpoint, options);
|
1112
|
-
|
1113
|
-
this._messageId = 0;
|
1114
|
-
this._state = this.UNCONNECTED;
|
1115
|
-
|
1116
|
-
this._responseCallbacks = {};
|
1117
|
-
|
1118
|
-
this._advice = {
|
1119
|
-
reconnect: this.RETRY,
|
1120
|
-
interval: 1000 * (options.interval || this.INTERVAL),
|
1121
|
-
timeout: 1000 * (options.timeout || this.CONNECTION_TIMEOUT)
|
1122
|
-
};
|
1123
|
-
this._dispatcher.timeout = this._advice.timeout / 1000;
|
1124
|
-
|
1125
|
-
this._dispatcher.bind('message', this._receiveMessage, this);
|
1126
|
-
|
1127
|
-
if (Faye.Event && Faye.ENV.onbeforeunload !== undefined)
|
1128
|
-
Faye.Event.on(Faye.ENV, 'beforeunload', function() {
|
1129
|
-
if (Faye.indexOf(this._dispatcher._disabled, 'autodisconnect') < 0)
|
1130
|
-
this.disconnect();
|
1131
|
-
}, this);
|
1132
|
-
},
|
1133
|
-
|
1134
|
-
addWebsocketExtension: function(extension) {
|
1135
|
-
return this._dispatcher.addWebsocketExtension(extension);
|
1136
|
-
},
|
1137
|
-
|
1138
|
-
disable: function(feature) {
|
1139
|
-
return this._dispatcher.disable(feature);
|
1140
|
-
},
|
1141
|
-
|
1142
|
-
setHeader: function(name, value) {
|
1143
|
-
return this._dispatcher.setHeader(name, value);
|
1144
|
-
},
|
1145
|
-
|
1146
|
-
// Request
|
1147
|
-
// MUST include: * channel
|
1148
|
-
// * version
|
1149
|
-
// * supportedConnectionTypes
|
1150
|
-
// MAY include: * minimumVersion
|
1151
|
-
// * ext
|
1152
|
-
// * id
|
1153
|
-
//
|
1154
|
-
// Success Response Failed Response
|
1155
|
-
// MUST include: * channel MUST include: * channel
|
1156
|
-
// * version * successful
|
1157
|
-
// * supportedConnectionTypes * error
|
1158
|
-
// * clientId MAY include: * supportedConnectionTypes
|
1159
|
-
// * successful * advice
|
1160
|
-
// MAY include: * minimumVersion * version
|
1161
|
-
// * advice * minimumVersion
|
1162
|
-
// * ext * ext
|
1163
|
-
// * id * id
|
1164
|
-
// * authSuccessful
|
1165
|
-
handshake: function(callback, context) {
|
1166
|
-
if (this._advice.reconnect === this.NONE) return;
|
1167
|
-
if (this._state !== this.UNCONNECTED) return;
|
1168
|
-
|
1169
|
-
this._state = this.CONNECTING;
|
1170
|
-
var self = this;
|
1171
|
-
|
1172
|
-
this.info('Initiating handshake with ?', Faye.URI.stringify(this._endpoint));
|
1173
|
-
this._dispatcher.selectTransport(Faye.MANDATORY_CONNECTION_TYPES);
|
1174
|
-
|
1175
|
-
this._sendMessage({
|
1176
|
-
channel: Faye.Channel.HANDSHAKE,
|
1177
|
-
version: Faye.BAYEUX_VERSION,
|
1178
|
-
supportedConnectionTypes: this._dispatcher.getConnectionTypes()
|
1179
|
-
|
1180
|
-
}, {}, function(response) {
|
1181
|
-
|
1182
|
-
if (response.successful) {
|
1183
|
-
this._state = this.CONNECTED;
|
1184
|
-
this._dispatcher.clientId = response.clientId;
|
1185
|
-
|
1186
|
-
this._dispatcher.selectTransport(response.supportedConnectionTypes);
|
1187
|
-
|
1188
|
-
this.info('Handshake successful: ?', this._dispatcher.clientId);
|
1189
|
-
|
1190
|
-
this.subscribe(this._channels.getKeys(), true);
|
1191
|
-
if (callback) Faye.Promise.defer(function() { callback.call(context) });
|
1192
|
-
|
1193
|
-
} else {
|
1194
|
-
this.info('Handshake unsuccessful');
|
1195
|
-
Faye.ENV.setTimeout(function() { self.handshake(callback, context) }, this._dispatcher.retry * 1000);
|
1196
|
-
this._state = this.UNCONNECTED;
|
1197
|
-
}
|
1198
|
-
}, this);
|
1199
|
-
},
|
1200
|
-
|
1201
|
-
// Request Response
|
1202
|
-
// MUST include: * channel MUST include: * channel
|
1203
|
-
// * clientId * successful
|
1204
|
-
// * connectionType * clientId
|
1205
|
-
// MAY include: * ext MAY include: * error
|
1206
|
-
// * id * advice
|
1207
|
-
// * ext
|
1208
|
-
// * id
|
1209
|
-
// * timestamp
|
1210
|
-
connect: function(callback, context) {
|
1211
|
-
if (this._advice.reconnect === this.NONE) return;
|
1212
|
-
if (this._state === this.DISCONNECTED) return;
|
1213
|
-
|
1214
|
-
if (this._state === this.UNCONNECTED)
|
1215
|
-
return this.handshake(function() { this.connect(callback, context) }, this);
|
1216
|
-
|
1217
|
-
this.callback(callback, context);
|
1218
|
-
if (this._state !== this.CONNECTED) return;
|
1219
|
-
|
1220
|
-
this.info('Calling deferred actions for ?', this._dispatcher.clientId);
|
1221
|
-
this.setDeferredStatus('succeeded');
|
1222
|
-
this.setDeferredStatus('unknown');
|
1223
|
-
|
1224
|
-
if (this._connectRequest) return;
|
1225
|
-
this._connectRequest = true;
|
1226
|
-
|
1227
|
-
this.info('Initiating connection for ?', this._dispatcher.clientId);
|
1228
|
-
|
1229
|
-
this._sendMessage({
|
1230
|
-
channel: Faye.Channel.CONNECT,
|
1231
|
-
clientId: this._dispatcher.clientId,
|
1232
|
-
connectionType: this._dispatcher.connectionType
|
1233
|
-
|
1234
|
-
}, {}, this._cycleConnection, this);
|
1235
|
-
},
|
1236
|
-
|
1237
|
-
// Request Response
|
1238
|
-
// MUST include: * channel MUST include: * channel
|
1239
|
-
// * clientId * successful
|
1240
|
-
// MAY include: * ext * clientId
|
1241
|
-
// * id MAY include: * error
|
1242
|
-
// * ext
|
1243
|
-
// * id
|
1244
|
-
disconnect: function() {
|
1245
|
-
if (this._state !== this.CONNECTED) return;
|
1246
|
-
this._state = this.DISCONNECTED;
|
1247
|
-
|
1248
|
-
this.info('Disconnecting ?', this._dispatcher.clientId);
|
1249
|
-
var promise = new Faye.Publication();
|
1250
|
-
|
1251
|
-
this._sendMessage({
|
1252
|
-
channel: Faye.Channel.DISCONNECT,
|
1253
|
-
clientId: this._dispatcher.clientId
|
1254
|
-
|
1255
|
-
}, {}, function(response) {
|
1256
|
-
if (response.successful) {
|
1257
|
-
this._dispatcher.close();
|
1258
|
-
promise.setDeferredStatus('succeeded');
|
1259
|
-
} else {
|
1260
|
-
promise.setDeferredStatus('failed', Faye.Error.parse(response.error));
|
1261
|
-
}
|
1262
|
-
}, this);
|
1263
|
-
|
1264
|
-
this.info('Clearing channel listeners for ?', this._dispatcher.clientId);
|
1265
|
-
this._channels = new Faye.Channel.Set();
|
1266
|
-
|
1267
|
-
return promise;
|
1268
|
-
},
|
1269
|
-
|
1270
|
-
// Request Response
|
1271
|
-
// MUST include: * channel MUST include: * channel
|
1272
|
-
// * clientId * successful
|
1273
|
-
// * subscription * clientId
|
1274
|
-
// MAY include: * ext * subscription
|
1275
|
-
// * id MAY include: * error
|
1276
|
-
// * advice
|
1277
|
-
// * ext
|
1278
|
-
// * id
|
1279
|
-
// * timestamp
|
1280
|
-
subscribe: function(channel, callback, context) {
|
1281
|
-
if (channel instanceof Array)
|
1282
|
-
return Faye.map(channel, function(c) {
|
1283
|
-
return this.subscribe(c, callback, context);
|
1284
|
-
}, this);
|
1285
|
-
|
1286
|
-
var subscription = new Faye.Subscription(this, channel, callback, context),
|
1287
|
-
force = (callback === true),
|
1288
|
-
hasSubscribe = this._channels.hasSubscription(channel);
|
1289
|
-
|
1290
|
-
if (hasSubscribe && !force) {
|
1291
|
-
this._channels.subscribe([channel], callback, context);
|
1292
|
-
subscription.setDeferredStatus('succeeded');
|
1293
|
-
return subscription;
|
1294
|
-
}
|
1295
|
-
|
1296
|
-
this.connect(function() {
|
1297
|
-
this.info('Client ? attempting to subscribe to ?', this._dispatcher.clientId, channel);
|
1298
|
-
if (!force) this._channels.subscribe([channel], callback, context);
|
1299
|
-
|
1300
|
-
this._sendMessage({
|
1301
|
-
channel: Faye.Channel.SUBSCRIBE,
|
1302
|
-
clientId: this._dispatcher.clientId,
|
1303
|
-
subscription: channel
|
1304
|
-
|
1305
|
-
}, {}, function(response) {
|
1306
|
-
if (!response.successful) {
|
1307
|
-
subscription.setDeferredStatus('failed', Faye.Error.parse(response.error));
|
1308
|
-
return this._channels.unsubscribe(channel, callback, context);
|
1309
|
-
}
|
1310
|
-
|
1311
|
-
var channels = [].concat(response.subscription);
|
1312
|
-
this.info('Subscription acknowledged for ? to ?', this._dispatcher.clientId, channels);
|
1313
|
-
subscription.setDeferredStatus('succeeded');
|
1314
|
-
}, this);
|
1315
|
-
}, this);
|
1316
|
-
|
1317
|
-
return subscription;
|
1318
|
-
},
|
1319
|
-
|
1320
|
-
// Request Response
|
1321
|
-
// MUST include: * channel MUST include: * channel
|
1322
|
-
// * clientId * successful
|
1323
|
-
// * subscription * clientId
|
1324
|
-
// MAY include: * ext * subscription
|
1325
|
-
// * id MAY include: * error
|
1326
|
-
// * advice
|
1327
|
-
// * ext
|
1328
|
-
// * id
|
1329
|
-
// * timestamp
|
1330
|
-
unsubscribe: function(channel, callback, context) {
|
1331
|
-
if (channel instanceof Array)
|
1332
|
-
return Faye.map(channel, function(c) {
|
1333
|
-
return this.unsubscribe(c, callback, context);
|
1334
|
-
}, this);
|
1335
|
-
|
1336
|
-
var dead = this._channels.unsubscribe(channel, callback, context);
|
1337
|
-
if (!dead) return;
|
1338
|
-
|
1339
|
-
this.connect(function() {
|
1340
|
-
this.info('Client ? attempting to unsubscribe from ?', this._dispatcher.clientId, channel);
|
1341
|
-
|
1342
|
-
this._sendMessage({
|
1343
|
-
channel: Faye.Channel.UNSUBSCRIBE,
|
1344
|
-
clientId: this._dispatcher.clientId,
|
1345
|
-
subscription: channel
|
1346
|
-
|
1347
|
-
}, {}, function(response) {
|
1348
|
-
if (!response.successful) return;
|
1349
|
-
|
1350
|
-
var channels = [].concat(response.subscription);
|
1351
|
-
this.info('Unsubscription acknowledged for ? from ?', this._dispatcher.clientId, channels);
|
1352
|
-
}, this);
|
1353
|
-
}, this);
|
1354
|
-
},
|
1355
|
-
|
1356
|
-
// Request Response
|
1357
|
-
// MUST include: * channel MUST include: * channel
|
1358
|
-
// * data * successful
|
1359
|
-
// MAY include: * clientId MAY include: * id
|
1360
|
-
// * id * error
|
1361
|
-
// * ext * ext
|
1362
|
-
publish: function(channel, data, options) {
|
1363
|
-
Faye.validateOptions(options || {}, ['attempts', 'deadline']);
|
1364
|
-
var publication = new Faye.Publication();
|
1365
|
-
|
1366
|
-
this.connect(function() {
|
1367
|
-
this.info('Client ? queueing published message to ?: ?', this._dispatcher.clientId, channel, data);
|
1368
|
-
|
1369
|
-
this._sendMessage({
|
1370
|
-
channel: channel,
|
1371
|
-
data: data,
|
1372
|
-
clientId: this._dispatcher.clientId
|
1373
|
-
|
1374
|
-
}, options, function(response) {
|
1375
|
-
if (response.successful)
|
1376
|
-
publication.setDeferredStatus('succeeded');
|
1377
|
-
else
|
1378
|
-
publication.setDeferredStatus('failed', Faye.Error.parse(response.error));
|
1379
|
-
}, this);
|
1380
|
-
}, this);
|
1381
|
-
|
1382
|
-
return publication;
|
1383
|
-
},
|
1384
|
-
|
1385
|
-
_sendMessage: function(message, options, callback, context) {
|
1386
|
-
message.id = this._generateMessageId();
|
1387
|
-
|
1388
|
-
var timeout = this._advice.timeout
|
1389
|
-
? 1.2 * this._advice.timeout / 1000
|
1390
|
-
: 1.2 * this._dispatcher.retry;
|
1391
|
-
|
1392
|
-
this.pipeThroughExtensions('outgoing', message, null, function(message) {
|
1393
|
-
if (!message) return;
|
1394
|
-
if (callback) this._responseCallbacks[message.id] = [callback, context];
|
1395
|
-
this._dispatcher.sendMessage(message, timeout, options || {});
|
1396
|
-
}, this);
|
1397
|
-
},
|
1398
|
-
|
1399
|
-
_generateMessageId: function() {
|
1400
|
-
this._messageId += 1;
|
1401
|
-
if (this._messageId >= Math.pow(2,32)) this._messageId = 0;
|
1402
|
-
return this._messageId.toString(36);
|
1403
|
-
},
|
1404
|
-
|
1405
|
-
_receiveMessage: function(message) {
|
1406
|
-
var id = message.id, callback;
|
1407
|
-
|
1408
|
-
if (message.successful !== undefined) {
|
1409
|
-
callback = this._responseCallbacks[id];
|
1410
|
-
delete this._responseCallbacks[id];
|
1411
|
-
}
|
1412
|
-
|
1413
|
-
this.pipeThroughExtensions('incoming', message, null, function(message) {
|
1414
|
-
if (!message) return;
|
1415
|
-
if (message.advice) this._handleAdvice(message.advice);
|
1416
|
-
this._deliverMessage(message);
|
1417
|
-
if (callback) callback[0].call(callback[1], message);
|
1418
|
-
}, this);
|
1419
|
-
},
|
1420
|
-
|
1421
|
-
_handleAdvice: function(advice) {
|
1422
|
-
Faye.extend(this._advice, advice);
|
1423
|
-
this._dispatcher.timeout = this._advice.timeout / 1000;
|
1424
|
-
|
1425
|
-
if (this._advice.reconnect === this.HANDSHAKE && this._state !== this.DISCONNECTED) {
|
1426
|
-
this._state = this.UNCONNECTED;
|
1427
|
-
this._dispatcher.clientId = null;
|
1428
|
-
this._cycleConnection();
|
1429
|
-
}
|
1430
|
-
},
|
1431
|
-
|
1432
|
-
_deliverMessage: function(message) {
|
1433
|
-
if (!message.channel || message.data === undefined) return;
|
1434
|
-
this.info('Client ? calling listeners for ? with ?', this._dispatcher.clientId, message.channel, message.data);
|
1435
|
-
this._channels.distributeMessage(message);
|
1436
|
-
},
|
1437
|
-
|
1438
|
-
_cycleConnection: function() {
|
1439
|
-
if (this._connectRequest) {
|
1440
|
-
this._connectRequest = null;
|
1441
|
-
this.info('Closed connection for ?', this._dispatcher.clientId);
|
1442
|
-
}
|
1443
|
-
var self = this;
|
1444
|
-
Faye.ENV.setTimeout(function() { self.connect() }, this._advice.interval);
|
1445
|
-
}
|
1446
|
-
});
|
1447
|
-
|
1448
|
-
Faye.extend(Faye.Client.prototype, Faye.Deferrable);
|
1449
|
-
Faye.extend(Faye.Client.prototype, Faye.Publisher);
|
1450
|
-
Faye.extend(Faye.Client.prototype, Faye.Logging);
|
1451
|
-
Faye.extend(Faye.Client.prototype, Faye.Extensible);
|
1452
|
-
|
1453
|
-
Faye.Dispatcher = Faye.Class({
|
1454
|
-
MAX_REQUEST_SIZE: 2048,
|
1455
|
-
DEFAULT_RETRY: 5,
|
1456
|
-
|
1457
|
-
UP: 1,
|
1458
|
-
DOWN: 2,
|
1459
|
-
|
1460
|
-
initialize: function(client, endpoint, options) {
|
1461
|
-
this._client = client;
|
1462
|
-
this.endpoint = Faye.URI.parse(endpoint);
|
1463
|
-
this._alternates = options.endpoints || {};
|
1464
|
-
|
1465
|
-
this.cookies = Faye.Cookies && new Faye.Cookies.CookieJar();
|
1466
|
-
this._disabled = [];
|
1467
|
-
this._envelopes = {};
|
1468
|
-
this.headers = {};
|
1469
|
-
this.retry = options.retry || this.DEFAULT_RETRY;
|
1470
|
-
this._scheduler = options.scheduler || Faye.Scheduler;
|
1471
|
-
this._state = 0;
|
1472
|
-
this.transports = {};
|
1473
|
-
this.wsExtensions = [];
|
1474
|
-
|
1475
|
-
this.proxy = options.proxy || {};
|
1476
|
-
if (typeof this._proxy === 'string') this._proxy = {origin: this._proxy};
|
1477
|
-
|
1478
|
-
var exts = options.websocketExtensions;
|
1479
|
-
if (exts) {
|
1480
|
-
exts = [].concat(exts);
|
1481
|
-
for (var i = 0, n = exts.length; i < n; i++)
|
1482
|
-
this.addWebsocketExtension(exts[i]);
|
1483
|
-
}
|
1484
|
-
|
1485
|
-
this.tls = options.tls || {};
|
1486
|
-
this.tls.ca = this.tls.ca || options.ca;
|
1487
|
-
|
1488
|
-
for (var type in this._alternates)
|
1489
|
-
this._alternates[type] = Faye.URI.parse(this._alternates[type]);
|
1490
|
-
|
1491
|
-
this.maxRequestSize = this.MAX_REQUEST_SIZE;
|
1492
|
-
},
|
1493
|
-
|
1494
|
-
endpointFor: function(connectionType) {
|
1495
|
-
return this._alternates[connectionType] || this.endpoint;
|
1496
|
-
},
|
1497
|
-
|
1498
|
-
addWebsocketExtension: function(extension) {
|
1499
|
-
this.wsExtensions.push(extension);
|
1500
|
-
},
|
1501
|
-
|
1502
|
-
disable: function(feature) {
|
1503
|
-
this._disabled.push(feature);
|
1504
|
-
},
|
1505
|
-
|
1506
|
-
setHeader: function(name, value) {
|
1507
|
-
this.headers[name] = value;
|
1508
|
-
},
|
1509
|
-
|
1510
|
-
close: function() {
|
1511
|
-
var transport = this._transport;
|
1512
|
-
delete this._transport;
|
1513
|
-
if (transport) transport.close();
|
1514
|
-
},
|
1515
|
-
|
1516
|
-
getConnectionTypes: function() {
|
1517
|
-
return Faye.Transport.getConnectionTypes();
|
1518
|
-
},
|
1519
|
-
|
1520
|
-
selectTransport: function(transportTypes) {
|
1521
|
-
Faye.Transport.get(this, transportTypes, this._disabled, function(transport) {
|
1522
|
-
this.debug('Selected ? transport for ?', transport.connectionType, Faye.URI.stringify(transport.endpoint));
|
1523
|
-
|
1524
|
-
if (transport === this._transport) return;
|
1525
|
-
if (this._transport) this._transport.close();
|
1526
|
-
|
1527
|
-
this._transport = transport;
|
1528
|
-
this.connectionType = transport.connectionType;
|
1529
|
-
}, this);
|
1530
|
-
},
|
1531
|
-
|
1532
|
-
sendMessage: function(message, timeout, options) {
|
1533
|
-
options = options || {};
|
1534
|
-
|
1535
|
-
var id = message.id,
|
1536
|
-
attempts = options.attempts,
|
1537
|
-
deadline = options.deadline && new Date().getTime() + (options.deadline * 1000),
|
1538
|
-
envelope = this._envelopes[id],
|
1539
|
-
scheduler;
|
1540
|
-
|
1541
|
-
if (!envelope) {
|
1542
|
-
scheduler = new this._scheduler(message, {timeout: timeout, interval: this.retry, attempts: attempts, deadline: deadline});
|
1543
|
-
envelope = this._envelopes[id] = {message: message, scheduler: scheduler};
|
1544
|
-
}
|
1545
|
-
|
1546
|
-
this._sendEnvelope(envelope);
|
1547
|
-
},
|
1548
|
-
|
1549
|
-
_sendEnvelope: function(envelope) {
|
1550
|
-
if (!this._transport) return;
|
1551
|
-
if (envelope.request || envelope.timer) return;
|
1552
|
-
|
1553
|
-
var message = envelope.message,
|
1554
|
-
scheduler = envelope.scheduler,
|
1555
|
-
self = this;
|
1556
|
-
|
1557
|
-
if (!scheduler.isDeliverable()) {
|
1558
|
-
scheduler.abort();
|
1559
|
-
delete this._envelopes[message.id];
|
1560
|
-
return;
|
1561
|
-
}
|
1562
|
-
|
1563
|
-
envelope.timer = Faye.ENV.setTimeout(function() {
|
1564
|
-
self.handleError(message);
|
1565
|
-
}, scheduler.getTimeout() * 1000);
|
1566
|
-
|
1567
|
-
scheduler.send();
|
1568
|
-
envelope.request = this._transport.sendMessage(message);
|
1569
|
-
},
|
1570
|
-
|
1571
|
-
handleResponse: function(reply) {
|
1572
|
-
var envelope = this._envelopes[reply.id];
|
1573
|
-
|
1574
|
-
if (reply.successful !== undefined && envelope) {
|
1575
|
-
envelope.scheduler.succeed();
|
1576
|
-
delete this._envelopes[reply.id];
|
1577
|
-
Faye.ENV.clearTimeout(envelope.timer);
|
1578
|
-
}
|
1579
|
-
|
1580
|
-
this.trigger('message', reply);
|
1581
|
-
|
1582
|
-
if (this._state === this.UP) return;
|
1583
|
-
this._state = this.UP;
|
1584
|
-
this._client.trigger('transport:up');
|
1585
|
-
},
|
1586
|
-
|
1587
|
-
handleError: function(message, immediate) {
|
1588
|
-
var envelope = this._envelopes[message.id],
|
1589
|
-
request = envelope && envelope.request,
|
1590
|
-
self = this;
|
1591
|
-
|
1592
|
-
if (!request) return;
|
1593
|
-
|
1594
|
-
request.then(function(req) {
|
1595
|
-
if (req && req.abort) req.abort();
|
1596
|
-
});
|
1597
|
-
|
1598
|
-
var scheduler = envelope.scheduler;
|
1599
|
-
scheduler.fail();
|
1600
|
-
|
1601
|
-
Faye.ENV.clearTimeout(envelope.timer);
|
1602
|
-
envelope.request = envelope.timer = null;
|
1603
|
-
|
1604
|
-
if (immediate) {
|
1605
|
-
this._sendEnvelope(envelope);
|
1606
|
-
} else {
|
1607
|
-
envelope.timer = Faye.ENV.setTimeout(function() {
|
1608
|
-
envelope.timer = null;
|
1609
|
-
self._sendEnvelope(envelope);
|
1610
|
-
}, scheduler.getInterval() * 1000);
|
1611
|
-
}
|
1612
|
-
|
1613
|
-
if (this._state === this.DOWN) return;
|
1614
|
-
this._state = this.DOWN;
|
1615
|
-
this._client.trigger('transport:down');
|
1616
|
-
}
|
1617
|
-
});
|
1618
|
-
|
1619
|
-
Faye.extend(Faye.Dispatcher.prototype, Faye.Publisher);
|
1620
|
-
Faye.extend(Faye.Dispatcher.prototype, Faye.Logging);
|
1621
|
-
|
1622
|
-
Faye.Scheduler = function(message, options) {
|
1623
|
-
this.message = message;
|
1624
|
-
this.options = options;
|
1625
|
-
this.attempts = 0;
|
1626
|
-
};
|
1627
|
-
|
1628
|
-
Faye.extend(Faye.Scheduler.prototype, {
|
1629
|
-
getTimeout: function() {
|
1630
|
-
return this.options.timeout;
|
1631
|
-
},
|
1632
|
-
|
1633
|
-
getInterval: function() {
|
1634
|
-
return this.options.interval;
|
1635
|
-
},
|
1636
|
-
|
1637
|
-
isDeliverable: function() {
|
1638
|
-
var attempts = this.options.attempts,
|
1639
|
-
made = this.attempts,
|
1640
|
-
deadline = this.options.deadline,
|
1641
|
-
now = new Date().getTime();
|
1642
|
-
|
1643
|
-
if (attempts !== undefined && made >= attempts)
|
1644
|
-
return false;
|
1645
|
-
|
1646
|
-
if (deadline !== undefined && now > deadline)
|
1647
|
-
return false;
|
1648
|
-
|
1649
|
-
return true;
|
1650
|
-
},
|
1651
|
-
|
1652
|
-
send: function() {
|
1653
|
-
this.attempts += 1;
|
1654
|
-
},
|
1655
|
-
|
1656
|
-
succeed: function() {},
|
1657
|
-
|
1658
|
-
fail: function() {},
|
1659
|
-
|
1660
|
-
abort: function() {}
|
1661
|
-
});
|
1662
|
-
|
1663
|
-
Faye.Transport = Faye.extend(Faye.Class({
|
1664
|
-
DEFAULT_PORTS: {'http:': 80, 'https:': 443, 'ws:': 80, 'wss:': 443},
|
1665
|
-
SECURE_PROTOCOLS: ['https:', 'wss:'],
|
1666
|
-
MAX_DELAY: 0,
|
1667
|
-
|
1668
|
-
batching: true,
|
1669
|
-
|
1670
|
-
initialize: function(dispatcher, endpoint) {
|
1671
|
-
this._dispatcher = dispatcher;
|
1672
|
-
this.endpoint = endpoint;
|
1673
|
-
this._outbox = [];
|
1674
|
-
this._proxy = Faye.extend({}, this._dispatcher.proxy);
|
1675
|
-
|
1676
|
-
if (!this._proxy.origin && Faye.NodeAdapter) {
|
1677
|
-
this._proxy.origin = Faye.indexOf(this.SECURE_PROTOCOLS, this.endpoint.protocol) >= 0
|
1678
|
-
? (process.env.HTTPS_PROXY || process.env.https_proxy)
|
1679
|
-
: (process.env.HTTP_PROXY || process.env.http_proxy);
|
1680
|
-
}
|
1681
|
-
},
|
1682
|
-
|
1683
|
-
close: function() {},
|
1684
|
-
|
1685
|
-
encode: function(messages) {
|
1686
|
-
return '';
|
1687
|
-
},
|
1688
|
-
|
1689
|
-
sendMessage: function(message) {
|
1690
|
-
this.debug('Client ? sending message to ?: ?',
|
1691
|
-
this._dispatcher.clientId, Faye.URI.stringify(this.endpoint), message);
|
1692
|
-
|
1693
|
-
if (!this.batching) return Faye.Promise.fulfilled(this.request([message]));
|
1694
|
-
|
1695
|
-
this._outbox.push(message);
|
1696
|
-
this._promise = this._promise || new Faye.Promise();
|
1697
|
-
this._flushLargeBatch();
|
1698
|
-
|
1699
|
-
if (message.channel === Faye.Channel.HANDSHAKE) {
|
1700
|
-
this.addTimeout('publish', 0.01, this._flush, this);
|
1701
|
-
return this._promise;
|
1702
|
-
}
|
1703
|
-
|
1704
|
-
if (message.channel === Faye.Channel.CONNECT)
|
1705
|
-
this._connectMessage = message;
|
1706
|
-
|
1707
|
-
this.addTimeout('publish', this.MAX_DELAY, this._flush, this);
|
1708
|
-
return this._promise;
|
1709
|
-
},
|
1710
|
-
|
1711
|
-
_flush: function() {
|
1712
|
-
this.removeTimeout('publish');
|
1713
|
-
|
1714
|
-
if (this._outbox.length > 1 && this._connectMessage)
|
1715
|
-
this._connectMessage.advice = {timeout: 0};
|
1716
|
-
|
1717
|
-
Faye.Promise.fulfill(this._promise, this.request(this._outbox));
|
1718
|
-
delete this._promise;
|
1719
|
-
|
1720
|
-
this._connectMessage = null;
|
1721
|
-
this._outbox = [];
|
1722
|
-
},
|
1723
|
-
|
1724
|
-
_flushLargeBatch: function() {
|
1725
|
-
var string = this.encode(this._outbox);
|
1726
|
-
if (string.length < this._dispatcher.maxRequestSize) return;
|
1727
|
-
var last = this._outbox.pop();
|
1728
|
-
this._flush();
|
1729
|
-
if (last) this._outbox.push(last);
|
1730
|
-
},
|
1731
|
-
|
1732
|
-
_receive: function(replies) {
|
1733
|
-
if (!replies) return;
|
1734
|
-
replies = [].concat(replies);
|
1735
|
-
|
1736
|
-
this.debug('Client ? received from ? via ?: ?',
|
1737
|
-
this._dispatcher.clientId, Faye.URI.stringify(this.endpoint), this.connectionType, replies);
|
1738
|
-
|
1739
|
-
for (var i = 0, n = replies.length; i < n; i++)
|
1740
|
-
this._dispatcher.handleResponse(replies[i]);
|
1741
|
-
},
|
1742
|
-
|
1743
|
-
_handleError: function(messages, immediate) {
|
1744
|
-
messages = [].concat(messages);
|
1745
|
-
|
1746
|
-
this.debug('Client ? failed to send to ? via ?: ?',
|
1747
|
-
this._dispatcher.clientId, Faye.URI.stringify(this.endpoint), this.connectionType, messages);
|
1748
|
-
|
1749
|
-
for (var i = 0, n = messages.length; i < n; i++)
|
1750
|
-
this._dispatcher.handleError(messages[i]);
|
1751
|
-
},
|
1752
|
-
|
1753
|
-
_getCookies: function() {
|
1754
|
-
var cookies = this._dispatcher.cookies,
|
1755
|
-
url = Faye.URI.stringify(this.endpoint);
|
1756
|
-
|
1757
|
-
if (!cookies) return '';
|
1758
|
-
|
1759
|
-
return Faye.map(cookies.getCookiesSync(url), function(cookie) {
|
1760
|
-
return cookie.cookieString();
|
1761
|
-
}).join('; ');
|
1762
|
-
},
|
1763
|
-
|
1764
|
-
_storeCookies: function(setCookie) {
|
1765
|
-
var cookies = this._dispatcher.cookies,
|
1766
|
-
url = Faye.URI.stringify(this.endpoint),
|
1767
|
-
cookie;
|
1768
|
-
|
1769
|
-
if (!setCookie || !cookies) return;
|
1770
|
-
setCookie = [].concat(setCookie);
|
1771
|
-
|
1772
|
-
for (var i = 0, n = setCookie.length; i < n; i++) {
|
1773
|
-
cookie = Faye.Cookies.Cookie.parse(setCookie[i]);
|
1774
|
-
cookies.setCookieSync(cookie, url);
|
1775
|
-
}
|
1776
|
-
}
|
1777
|
-
|
1778
|
-
}), {
|
1779
|
-
get: function(dispatcher, allowed, disabled, callback, context) {
|
1780
|
-
var endpoint = dispatcher.endpoint;
|
1781
|
-
|
1782
|
-
Faye.asyncEach(this._transports, function(pair, resume) {
|
1783
|
-
var connType = pair[0], klass = pair[1],
|
1784
|
-
connEndpoint = dispatcher.endpointFor(connType);
|
1785
|
-
|
1786
|
-
if (Faye.indexOf(disabled, connType) >= 0)
|
1787
|
-
return resume();
|
1788
|
-
|
1789
|
-
if (Faye.indexOf(allowed, connType) < 0) {
|
1790
|
-
klass.isUsable(dispatcher, connEndpoint, function() {});
|
1791
|
-
return resume();
|
1792
|
-
}
|
1793
|
-
|
1794
|
-
klass.isUsable(dispatcher, connEndpoint, function(isUsable) {
|
1795
|
-
if (!isUsable) return resume();
|
1796
|
-
var transport = klass.hasOwnProperty('create') ? klass.create(dispatcher, connEndpoint) : new klass(dispatcher, connEndpoint);
|
1797
|
-
callback.call(context, transport);
|
1798
|
-
});
|
1799
|
-
}, function() {
|
1800
|
-
throw new Error('Could not find a usable connection type for ' + Faye.URI.stringify(endpoint));
|
1801
|
-
});
|
1802
|
-
},
|
1803
|
-
|
1804
|
-
register: function(type, klass) {
|
1805
|
-
this._transports.push([type, klass]);
|
1806
|
-
klass.prototype.connectionType = type;
|
1807
|
-
},
|
1808
|
-
|
1809
|
-
getConnectionTypes: function() {
|
1810
|
-
return Faye.map(this._transports, function(t) { return t[0] });
|
1811
|
-
},
|
1812
|
-
|
1813
|
-
_transports: []
|
1814
|
-
});
|
1815
|
-
|
1816
|
-
Faye.extend(Faye.Transport.prototype, Faye.Logging);
|
1817
|
-
Faye.extend(Faye.Transport.prototype, Faye.Timeouts);
|
1818
|
-
|
1819
|
-
Faye.Event = {
|
1820
|
-
_registry: [],
|
1821
|
-
|
1822
|
-
on: function(element, eventName, callback, context) {
|
1823
|
-
var wrapped = function() { callback.call(context) };
|
1824
|
-
|
1825
|
-
if (element.addEventListener)
|
1826
|
-
element.addEventListener(eventName, wrapped, false);
|
1827
|
-
else
|
1828
|
-
element.attachEvent('on' + eventName, wrapped);
|
1829
|
-
|
1830
|
-
this._registry.push({
|
1831
|
-
_element: element,
|
1832
|
-
_type: eventName,
|
1833
|
-
_callback: callback,
|
1834
|
-
_context: context,
|
1835
|
-
_handler: wrapped
|
1836
|
-
});
|
1837
|
-
},
|
1838
|
-
|
1839
|
-
detach: function(element, eventName, callback, context) {
|
1840
|
-
var i = this._registry.length, register;
|
1841
|
-
while (i--) {
|
1842
|
-
register = this._registry[i];
|
1843
|
-
|
1844
|
-
if ((element && element !== register._element) ||
|
1845
|
-
(eventName && eventName !== register._type) ||
|
1846
|
-
(callback && callback !== register._callback) ||
|
1847
|
-
(context && context !== register._context))
|
1848
|
-
continue;
|
1849
|
-
|
1850
|
-
if (register._element.removeEventListener)
|
1851
|
-
register._element.removeEventListener(register._type, register._handler, false);
|
1852
|
-
else
|
1853
|
-
register._element.detachEvent('on' + register._type, register._handler);
|
1854
|
-
|
1855
|
-
this._registry.splice(i,1);
|
1856
|
-
register = null;
|
1857
|
-
}
|
1858
|
-
}
|
1859
|
-
};
|
1860
|
-
|
1861
|
-
if (Faye.ENV.onunload !== undefined) Faye.Event.on(Faye.ENV, 'unload', Faye.Event.detach, Faye.Event);
|
1862
|
-
|
1863
|
-
/*
|
1864
|
-
json2.js
|
1865
|
-
2013-05-26
|
1866
|
-
|
1867
|
-
Public Domain.
|
1868
|
-
|
1869
|
-
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
1870
|
-
|
1871
|
-
See http://www.JSON.org/js.html
|
1872
|
-
|
1873
|
-
|
1874
|
-
This code should be minified before deployment.
|
1875
|
-
See http://javascript.crockford.com/jsmin.html
|
1876
|
-
|
1877
|
-
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
1878
|
-
NOT CONTROL.
|
1879
|
-
|
1880
|
-
|
1881
|
-
This file creates a global JSON object containing two methods: stringify
|
1882
|
-
and parse.
|
1883
|
-
|
1884
|
-
JSON.stringify(value, replacer, space)
|
1885
|
-
value any JavaScript value, usually an object or array.
|
1886
|
-
|
1887
|
-
replacer an optional parameter that determines how object
|
1888
|
-
values are stringified for objects. It can be a
|
1889
|
-
function or an array of strings.
|
1890
|
-
|
1891
|
-
space an optional parameter that specifies the indentation
|
1892
|
-
of nested structures. If it is omitted, the text will
|
1893
|
-
be packed without extra whitespace. If it is a number,
|
1894
|
-
it will specify the number of spaces to indent at each
|
1895
|
-
level. If it is a string (such as '\t' or ' '),
|
1896
|
-
it contains the characters used to indent at each level.
|
1897
|
-
|
1898
|
-
This method produces a JSON text from a JavaScript value.
|
1899
|
-
|
1900
|
-
When an object value is found, if the object contains a toJSON
|
1901
|
-
method, its toJSON method will be called and the result will be
|
1902
|
-
stringified. A toJSON method does not serialize: it returns the
|
1903
|
-
value represented by the name/value pair that should be serialized,
|
1904
|
-
or undefined if nothing should be serialized. The toJSON method
|
1905
|
-
will be passed the key associated with the value, and this will be
|
1906
|
-
bound to the value
|
1907
|
-
|
1908
|
-
For example, this would serialize Dates as ISO strings.
|
1909
|
-
|
1910
|
-
Date.prototype.toJSON = function (key) {
|
1911
|
-
function f(n) {
|
1912
|
-
// Format integers to have at least two digits.
|
1913
|
-
return n < 10 ? '0' + n : n;
|
1914
|
-
}
|
1915
|
-
|
1916
|
-
return this.getUTCFullYear() + '-' +
|
1917
|
-
f(this.getUTCMonth() + 1) + '-' +
|
1918
|
-
f(this.getUTCDate()) + 'T' +
|
1919
|
-
f(this.getUTCHours()) + ':' +
|
1920
|
-
f(this.getUTCMinutes()) + ':' +
|
1921
|
-
f(this.getUTCSeconds()) + 'Z';
|
1922
|
-
};
|
1923
|
-
|
1924
|
-
You can provide an optional replacer method. It will be passed the
|
1925
|
-
key and value of each member, with this bound to the containing
|
1926
|
-
object. The value that is returned from your method will be
|
1927
|
-
serialized. If your method returns undefined, then the member will
|
1928
|
-
be excluded from the serialization.
|
1929
|
-
|
1930
|
-
If the replacer parameter is an array of strings, then it will be
|
1931
|
-
used to select the members to be serialized. It filters the results
|
1932
|
-
such that only members with keys listed in the replacer array are
|
1933
|
-
stringified.
|
1934
|
-
|
1935
|
-
Values that do not have JSON representations, such as undefined or
|
1936
|
-
functions, will not be serialized. Such values in objects will be
|
1937
|
-
dropped; in arrays they will be replaced with null. You can use
|
1938
|
-
a replacer function to replace those with JSON values.
|
1939
|
-
JSON.stringify(undefined) returns undefined.
|
1940
|
-
|
1941
|
-
The optional space parameter produces a stringification of the
|
1942
|
-
value that is filled with line breaks and indentation to make it
|
1943
|
-
easier to read.
|
1944
|
-
|
1945
|
-
If the space parameter is a non-empty string, then that string will
|
1946
|
-
be used for indentation. If the space parameter is a number, then
|
1947
|
-
the indentation will be that many spaces.
|
1948
|
-
|
1949
|
-
Example:
|
1950
|
-
|
1951
|
-
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
1952
|
-
// text is '["e",{"pluribus":"unum"}]'
|
1953
|
-
|
1954
|
-
|
1955
|
-
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
1956
|
-
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
1957
|
-
|
1958
|
-
text = JSON.stringify([new Date()], function (key, value) {
|
1959
|
-
return this[key] instanceof Date ?
|
1960
|
-
'Date(' + this[key] + ')' : value;
|
1961
|
-
});
|
1962
|
-
// text is '["Date(---current time---)"]'
|
1963
|
-
|
1964
|
-
|
1965
|
-
JSON.parse(text, reviver)
|
1966
|
-
This method parses a JSON text to produce an object or array.
|
1967
|
-
It can throw a SyntaxError exception.
|
1968
|
-
|
1969
|
-
The optional reviver parameter is a function that can filter and
|
1970
|
-
transform the results. It receives each of the keys and values,
|
1971
|
-
and its return value is used instead of the original value.
|
1972
|
-
If it returns what it received, then the structure is not modified.
|
1973
|
-
If it returns undefined then the member is deleted.
|
1974
|
-
|
1975
|
-
Example:
|
1976
|
-
|
1977
|
-
// Parse the text. Values that look like ISO date strings will
|
1978
|
-
// be converted to Date objects.
|
1979
|
-
|
1980
|
-
myData = JSON.parse(text, function (key, value) {
|
1981
|
-
var a;
|
1982
|
-
if (typeof value === 'string') {
|
1983
|
-
a =
|
1984
|
-
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
1985
|
-
if (a) {
|
1986
|
-
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
1987
|
-
+a[5], +a[6]));
|
1988
|
-
}
|
1989
|
-
}
|
1990
|
-
return value;
|
1991
|
-
});
|
1992
|
-
|
1993
|
-
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
1994
|
-
var d;
|
1995
|
-
if (typeof value === 'string' &&
|
1996
|
-
value.slice(0, 5) === 'Date(' &&
|
1997
|
-
value.slice(-1) === ')') {
|
1998
|
-
d = new Date(value.slice(5, -1));
|
1999
|
-
if (d) {
|
2000
|
-
return d;
|
2001
|
-
}
|
2002
|
-
}
|
2003
|
-
return value;
|
2004
|
-
});
|
2005
|
-
|
2006
|
-
|
2007
|
-
This is a reference implementation. You are free to copy, modify, or
|
2008
|
-
redistribute.
|
2009
|
-
*/
|
2010
|
-
|
2011
|
-
/*jslint evil: true, regexp: true */
|
2012
|
-
|
2013
|
-
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
2014
|
-
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
2015
|
-
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
2016
|
-
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
2017
|
-
test, toJSON, toString, valueOf
|
2018
|
-
*/
|
2019
|
-
|
2020
|
-
|
2021
|
-
// Create a JSON object only if one does not already exist. We create the
|
2022
|
-
// methods in a closure to avoid creating global variables.
|
2023
|
-
|
2024
|
-
if (typeof JSON !== 'object') {
|
2025
|
-
JSON = {};
|
2026
|
-
}
|
2027
|
-
|
2028
|
-
(function () {
|
2029
|
-
'use strict';
|
2030
|
-
|
2031
|
-
function f(n) {
|
2032
|
-
// Format integers to have at least two digits.
|
2033
|
-
return n < 10 ? '0' + n : n;
|
2034
|
-
}
|
2035
|
-
|
2036
|
-
if (typeof Date.prototype.toJSON !== 'function') {
|
2037
|
-
|
2038
|
-
Date.prototype.toJSON = function () {
|
2039
|
-
|
2040
|
-
return isFinite(this.valueOf())
|
2041
|
-
? this.getUTCFullYear() + '-' +
|
2042
|
-
f(this.getUTCMonth() + 1) + '-' +
|
2043
|
-
f(this.getUTCDate()) + 'T' +
|
2044
|
-
f(this.getUTCHours()) + ':' +
|
2045
|
-
f(this.getUTCMinutes()) + ':' +
|
2046
|
-
f(this.getUTCSeconds()) + 'Z'
|
2047
|
-
: null;
|
2048
|
-
};
|
2049
|
-
|
2050
|
-
String.prototype.toJSON =
|
2051
|
-
Number.prototype.toJSON =
|
2052
|
-
Boolean.prototype.toJSON = function () {
|
2053
|
-
return this.valueOf();
|
2054
|
-
};
|
2055
|
-
}
|
2056
|
-
|
2057
|
-
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
2058
|
-
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
2059
|
-
gap,
|
2060
|
-
indent,
|
2061
|
-
meta = { // table of character substitutions
|
2062
|
-
'\b': '\\b',
|
2063
|
-
'\t': '\\t',
|
2064
|
-
'\n': '\\n',
|
2065
|
-
'\f': '\\f',
|
2066
|
-
'\r': '\\r',
|
2067
|
-
'"' : '\\"',
|
2068
|
-
'\\': '\\\\'
|
2069
|
-
},
|
2070
|
-
rep;
|
2071
|
-
|
2072
|
-
|
2073
|
-
function quote(string) {
|
2074
|
-
|
2075
|
-
// If the string contains no control characters, no quote characters, and no
|
2076
|
-
// backslash characters, then we can safely slap some quotes around it.
|
2077
|
-
// Otherwise we must also replace the offending characters with safe escape
|
2078
|
-
// sequences.
|
2079
|
-
|
2080
|
-
escapable.lastIndex = 0;
|
2081
|
-
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
2082
|
-
var c = meta[a];
|
2083
|
-
return typeof c === 'string'
|
2084
|
-
? c
|
2085
|
-
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
2086
|
-
}) + '"' : '"' + string + '"';
|
2087
|
-
}
|
2088
|
-
|
2089
|
-
|
2090
|
-
function str(key, holder) {
|
2091
|
-
|
2092
|
-
// Produce a string from holder[key].
|
2093
|
-
|
2094
|
-
var i, // The loop counter.
|
2095
|
-
k, // The member key.
|
2096
|
-
v, // The member value.
|
2097
|
-
length,
|
2098
|
-
mind = gap,
|
2099
|
-
partial,
|
2100
|
-
value = holder[key];
|
2101
|
-
|
2102
|
-
// If the value has a toJSON method, call it to obtain a replacement value.
|
2103
|
-
|
2104
|
-
if (value && typeof value === 'object' &&
|
2105
|
-
typeof value.toJSON === 'function') {
|
2106
|
-
value = value.toJSON(key);
|
2107
|
-
}
|
2108
|
-
|
2109
|
-
// If we were called with a replacer function, then call the replacer to
|
2110
|
-
// obtain a replacement value.
|
2111
|
-
|
2112
|
-
if (typeof rep === 'function') {
|
2113
|
-
value = rep.call(holder, key, value);
|
2114
|
-
}
|
2115
|
-
|
2116
|
-
// What happens next depends on the value's type.
|
2117
|
-
|
2118
|
-
switch (typeof value) {
|
2119
|
-
case 'string':
|
2120
|
-
return quote(value);
|
2121
|
-
|
2122
|
-
case 'number':
|
2123
|
-
|
2124
|
-
// JSON numbers must be finite. Encode non-finite numbers as null.
|
2125
|
-
|
2126
|
-
return isFinite(value) ? String(value) : 'null';
|
2127
|
-
|
2128
|
-
case 'boolean':
|
2129
|
-
case 'null':
|
2130
|
-
|
2131
|
-
// If the value is a boolean or null, convert it to a string. Note:
|
2132
|
-
// typeof null does not produce 'null'. The case is included here in
|
2133
|
-
// the remote chance that this gets fixed someday.
|
2134
|
-
|
2135
|
-
return String(value);
|
2136
|
-
|
2137
|
-
// If the type is 'object', we might be dealing with an object or an array or
|
2138
|
-
// null.
|
2139
|
-
|
2140
|
-
case 'object':
|
2141
|
-
|
2142
|
-
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
2143
|
-
// so watch out for that case.
|
2144
|
-
|
2145
|
-
if (!value) {
|
2146
|
-
return 'null';
|
2147
|
-
}
|
2148
|
-
|
2149
|
-
// Make an array to hold the partial results of stringifying this object value.
|
2150
|
-
|
2151
|
-
gap += indent;
|
2152
|
-
partial = [];
|
2153
|
-
|
2154
|
-
// Is the value an array?
|
2155
|
-
|
2156
|
-
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
2157
|
-
|
2158
|
-
// The value is an array. Stringify every element. Use null as a placeholder
|
2159
|
-
// for non-JSON values.
|
2160
|
-
|
2161
|
-
length = value.length;
|
2162
|
-
for (i = 0; i < length; i += 1) {
|
2163
|
-
partial[i] = str(i, value) || 'null';
|
2164
|
-
}
|
2165
|
-
|
2166
|
-
// Join all of the elements together, separated with commas, and wrap them in
|
2167
|
-
// brackets.
|
2168
|
-
|
2169
|
-
v = partial.length === 0
|
2170
|
-
? '[]'
|
2171
|
-
: gap
|
2172
|
-
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
|
2173
|
-
: '[' + partial.join(',') + ']';
|
2174
|
-
gap = mind;
|
2175
|
-
return v;
|
2176
|
-
}
|
2177
|
-
|
2178
|
-
// If the replacer is an array, use it to select the members to be stringified.
|
2179
|
-
|
2180
|
-
if (rep && typeof rep === 'object') {
|
2181
|
-
length = rep.length;
|
2182
|
-
for (i = 0; i < length; i += 1) {
|
2183
|
-
if (typeof rep[i] === 'string') {
|
2184
|
-
k = rep[i];
|
2185
|
-
v = str(k, value);
|
2186
|
-
if (v) {
|
2187
|
-
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
2188
|
-
}
|
2189
|
-
}
|
2190
|
-
}
|
2191
|
-
} else {
|
2192
|
-
|
2193
|
-
// Otherwise, iterate through all of the keys in the object.
|
2194
|
-
|
2195
|
-
for (k in value) {
|
2196
|
-
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
2197
|
-
v = str(k, value);
|
2198
|
-
if (v) {
|
2199
|
-
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
2200
|
-
}
|
2201
|
-
}
|
2202
|
-
}
|
2203
|
-
}
|
2204
|
-
|
2205
|
-
// Join all of the member texts together, separated with commas,
|
2206
|
-
// and wrap them in braces.
|
2207
|
-
|
2208
|
-
v = partial.length === 0
|
2209
|
-
? '{}'
|
2210
|
-
: gap
|
2211
|
-
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
|
2212
|
-
: '{' + partial.join(',') + '}';
|
2213
|
-
gap = mind;
|
2214
|
-
return v;
|
2215
|
-
}
|
2216
|
-
}
|
2217
|
-
|
2218
|
-
// If the JSON object does not yet have a stringify method, give it one.
|
2219
|
-
|
2220
|
-
Faye.stringify = function (value, replacer, space) {
|
2221
|
-
|
2222
|
-
// The stringify method takes a value and an optional replacer, and an optional
|
2223
|
-
// space parameter, and returns a JSON text. The replacer can be a function
|
2224
|
-
// that can replace values, or an array of strings that will select the keys.
|
2225
|
-
// A default replacer method can be provided. Use of the space parameter can
|
2226
|
-
// produce text that is more easily readable.
|
2227
|
-
|
2228
|
-
var i;
|
2229
|
-
gap = '';
|
2230
|
-
indent = '';
|
2231
|
-
|
2232
|
-
// If the space parameter is a number, make an indent string containing that
|
2233
|
-
// many spaces.
|
2234
|
-
|
2235
|
-
if (typeof space === 'number') {
|
2236
|
-
for (i = 0; i < space; i += 1) {
|
2237
|
-
indent += ' ';
|
2238
|
-
}
|
2239
|
-
|
2240
|
-
// If the space parameter is a string, it will be used as the indent string.
|
2241
|
-
|
2242
|
-
} else if (typeof space === 'string') {
|
2243
|
-
indent = space;
|
2244
|
-
}
|
2245
|
-
|
2246
|
-
// If there is a replacer, it must be a function or an array.
|
2247
|
-
// Otherwise, throw an error.
|
2248
|
-
|
2249
|
-
rep = replacer;
|
2250
|
-
if (replacer && typeof replacer !== 'function' &&
|
2251
|
-
(typeof replacer !== 'object' ||
|
2252
|
-
typeof replacer.length !== 'number')) {
|
2253
|
-
throw new Error('JSON.stringify');
|
2254
|
-
}
|
2255
|
-
|
2256
|
-
// Make a fake root object containing our value under the key of ''.
|
2257
|
-
// Return the result of stringifying the value.
|
2258
|
-
|
2259
|
-
return str('', {'': value});
|
2260
|
-
};
|
2261
|
-
|
2262
|
-
if (typeof JSON.stringify !== 'function') {
|
2263
|
-
JSON.stringify = Faye.stringify;
|
2264
|
-
}
|
2265
|
-
|
2266
|
-
// If the JSON object does not yet have a parse method, give it one.
|
2267
|
-
|
2268
|
-
if (typeof JSON.parse !== 'function') {
|
2269
|
-
JSON.parse = function (text, reviver) {
|
2270
|
-
|
2271
|
-
// The parse method takes a text and an optional reviver function, and returns
|
2272
|
-
// a JavaScript value if the text is a valid JSON text.
|
2273
|
-
|
2274
|
-
var j;
|
2275
|
-
|
2276
|
-
function walk(holder, key) {
|
2277
|
-
|
2278
|
-
// The walk method is used to recursively walk the resulting structure so
|
2279
|
-
// that modifications can be made.
|
2280
|
-
|
2281
|
-
var k, v, value = holder[key];
|
2282
|
-
if (value && typeof value === 'object') {
|
2283
|
-
for (k in value) {
|
2284
|
-
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
2285
|
-
v = walk(value, k);
|
2286
|
-
if (v !== undefined) {
|
2287
|
-
value[k] = v;
|
2288
|
-
} else {
|
2289
|
-
delete value[k];
|
2290
|
-
}
|
2291
|
-
}
|
2292
|
-
}
|
2293
|
-
}
|
2294
|
-
return reviver.call(holder, key, value);
|
2295
|
-
}
|
2296
|
-
|
2297
|
-
|
2298
|
-
// Parsing happens in four stages. In the first stage, we replace certain
|
2299
|
-
// Unicode characters with escape sequences. JavaScript handles many characters
|
2300
|
-
// incorrectly, either silently deleting them, or treating them as line endings.
|
2301
|
-
|
2302
|
-
text = String(text);
|
2303
|
-
cx.lastIndex = 0;
|
2304
|
-
if (cx.test(text)) {
|
2305
|
-
text = text.replace(cx, function (a) {
|
2306
|
-
return '\\u' +
|
2307
|
-
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
2308
|
-
});
|
2309
|
-
}
|
2310
|
-
|
2311
|
-
// In the second stage, we run the text against regular expressions that look
|
2312
|
-
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
2313
|
-
// because they can cause invocation, and '=' because it can cause mutation.
|
2314
|
-
// But just to be safe, we want to reject all unexpected forms.
|
2315
|
-
|
2316
|
-
// We split the second stage into 4 regexp operations in order to work around
|
2317
|
-
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
2318
|
-
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
2319
|
-
// replace all simple value tokens with ']' characters. Third, we delete all
|
2320
|
-
// open brackets that follow a colon or comma or that begin the text. Finally,
|
2321
|
-
// we look to see that the remaining characters are only whitespace or ']' or
|
2322
|
-
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
2323
|
-
|
2324
|
-
if (/^[\],:{}\s]*$/
|
2325
|
-
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
|
2326
|
-
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
|
2327
|
-
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
2328
|
-
|
2329
|
-
// In the third stage we use the eval function to compile the text into a
|
2330
|
-
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
2331
|
-
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
2332
|
-
// in parens to eliminate the ambiguity.
|
2333
|
-
|
2334
|
-
j = eval('(' + text + ')');
|
2335
|
-
|
2336
|
-
// In the optional fourth stage, we recursively walk the new structure, passing
|
2337
|
-
// each name/value pair to a reviver function for possible transformation.
|
2338
|
-
|
2339
|
-
return typeof reviver === 'function'
|
2340
|
-
? walk({'': j}, '')
|
2341
|
-
: j;
|
2342
|
-
}
|
2343
|
-
|
2344
|
-
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
2345
|
-
|
2346
|
-
throw new SyntaxError('JSON.parse');
|
2347
|
-
};
|
2348
|
-
}
|
2349
|
-
}());
|
2350
|
-
|
2351
|
-
Faye.Transport.WebSocket = Faye.extend(Faye.Class(Faye.Transport, {
|
2352
|
-
UNCONNECTED: 1,
|
2353
|
-
CONNECTING: 2,
|
2354
|
-
CONNECTED: 3,
|
2355
|
-
|
2356
|
-
batching: false,
|
2357
|
-
|
2358
|
-
isUsable: function(callback, context) {
|
2359
|
-
this.callback(function() { callback.call(context, true) });
|
2360
|
-
this.errback(function() { callback.call(context, false) });
|
2361
|
-
this.connect();
|
2362
|
-
},
|
2363
|
-
|
2364
|
-
request: function(messages) {
|
2365
|
-
this._pending = this._pending || new Faye.Set();
|
2366
|
-
for (var i = 0, n = messages.length; i < n; i++) this._pending.add(messages[i]);
|
2367
|
-
|
2368
|
-
var promise = new Faye.Promise();
|
2369
|
-
|
2370
|
-
this.callback(function(socket) {
|
2371
|
-
if (!socket || socket.readyState !== 1) return;
|
2372
|
-
socket.send(Faye.toJSON(messages));
|
2373
|
-
Faye.Promise.fulfill(promise, socket);
|
2374
|
-
}, this);
|
2375
|
-
|
2376
|
-
this.connect();
|
2377
|
-
|
2378
|
-
return {
|
2379
|
-
abort: function() { promise.then(function(ws) { ws.close() }) }
|
2380
|
-
};
|
2381
|
-
},
|
2382
|
-
|
2383
|
-
connect: function() {
|
2384
|
-
if (Faye.Transport.WebSocket._unloaded) return;
|
2385
|
-
|
2386
|
-
this._state = this._state || this.UNCONNECTED;
|
2387
|
-
if (this._state !== this.UNCONNECTED) return;
|
2388
|
-
this._state = this.CONNECTING;
|
2389
|
-
|
2390
|
-
var socket = this._createSocket();
|
2391
|
-
if (!socket) return this.setDeferredStatus('failed');
|
2392
|
-
|
2393
|
-
var self = this;
|
2394
|
-
|
2395
|
-
socket.onopen = function() {
|
2396
|
-
if (socket.headers) self._storeCookies(socket.headers['set-cookie']);
|
2397
|
-
self._socket = socket;
|
2398
|
-
self._state = self.CONNECTED;
|
2399
|
-
self._everConnected = true;
|
2400
|
-
self._ping();
|
2401
|
-
self.setDeferredStatus('succeeded', socket);
|
2402
|
-
};
|
2403
|
-
|
2404
|
-
var closed = false;
|
2405
|
-
socket.onclose = socket.onerror = function() {
|
2406
|
-
if (closed) return;
|
2407
|
-
closed = true;
|
2408
|
-
|
2409
|
-
var wasConnected = (self._state === self.CONNECTED);
|
2410
|
-
socket.onopen = socket.onclose = socket.onerror = socket.onmessage = null;
|
2411
|
-
|
2412
|
-
delete self._socket;
|
2413
|
-
self._state = self.UNCONNECTED;
|
2414
|
-
self.removeTimeout('ping');
|
2415
|
-
self.setDeferredStatus('unknown');
|
2416
|
-
|
2417
|
-
var pending = self._pending ? self._pending.toArray() : [];
|
2418
|
-
delete self._pending;
|
2419
|
-
|
2420
|
-
if (wasConnected) {
|
2421
|
-
self._handleError(pending, true);
|
2422
|
-
} else if (self._everConnected) {
|
2423
|
-
self._handleError(pending);
|
2424
|
-
} else {
|
2425
|
-
self.setDeferredStatus('failed');
|
2426
|
-
}
|
2427
|
-
};
|
2428
|
-
|
2429
|
-
socket.onmessage = function(event) {
|
2430
|
-
var replies = JSON.parse(event.data);
|
2431
|
-
if (!replies) return;
|
2432
|
-
|
2433
|
-
replies = [].concat(replies);
|
2434
|
-
|
2435
|
-
for (var i = 0, n = replies.length; i < n; i++) {
|
2436
|
-
if (replies[i].successful === undefined) continue;
|
2437
|
-
self._pending.remove(replies[i]);
|
2438
|
-
}
|
2439
|
-
self._receive(replies);
|
2440
|
-
};
|
2441
|
-
},
|
2442
|
-
|
2443
|
-
close: function() {
|
2444
|
-
if (!this._socket) return;
|
2445
|
-
this._socket.close();
|
2446
|
-
},
|
2447
|
-
|
2448
|
-
_createSocket: function() {
|
2449
|
-
var url = Faye.Transport.WebSocket.getSocketUrl(this.endpoint),
|
2450
|
-
headers = this._dispatcher.headers,
|
2451
|
-
extensions = this._dispatcher.wsExtensions,
|
2452
|
-
cookie = this._getCookies(),
|
2453
|
-
tls = this._dispatcher.tls,
|
2454
|
-
options = {extensions: extensions, headers: headers, proxy: this._proxy, tls: tls};
|
2455
|
-
|
2456
|
-
if (cookie !== '') options.headers['Cookie'] = cookie;
|
2457
|
-
|
2458
|
-
if (Faye.WebSocket) return new Faye.WebSocket.Client(url, [], options);
|
2459
|
-
if (Faye.ENV.MozWebSocket) return new MozWebSocket(url);
|
2460
|
-
if (Faye.ENV.WebSocket) return new WebSocket(url);
|
2461
|
-
},
|
2462
|
-
|
2463
|
-
_ping: function() {
|
2464
|
-
if (!this._socket) return;
|
2465
|
-
this._socket.send('[]');
|
2466
|
-
this.addTimeout('ping', this._dispatcher.timeout / 2, this._ping, this);
|
2467
|
-
}
|
2468
|
-
|
2469
|
-
}), {
|
2470
|
-
PROTOCOLS: {
|
2471
|
-
'http:': 'ws:',
|
2472
|
-
'https:': 'wss:'
|
2473
|
-
},
|
2474
|
-
|
2475
|
-
create: function(dispatcher, endpoint) {
|
2476
|
-
var sockets = dispatcher.transports.websocket = dispatcher.transports.websocket || {};
|
2477
|
-
sockets[endpoint.href] = sockets[endpoint.href] || new this(dispatcher, endpoint);
|
2478
|
-
return sockets[endpoint.href];
|
2479
|
-
},
|
2480
|
-
|
2481
|
-
getSocketUrl: function(endpoint) {
|
2482
|
-
endpoint = Faye.copyObject(endpoint);
|
2483
|
-
endpoint.protocol = this.PROTOCOLS[endpoint.protocol];
|
2484
|
-
return Faye.URI.stringify(endpoint);
|
2485
|
-
},
|
2486
|
-
|
2487
|
-
isUsable: function(dispatcher, endpoint, callback, context) {
|
2488
|
-
this.create(dispatcher, endpoint).isUsable(callback, context);
|
2489
|
-
}
|
2490
|
-
});
|
2491
|
-
|
2492
|
-
Faye.extend(Faye.Transport.WebSocket.prototype, Faye.Deferrable);
|
2493
|
-
Faye.Transport.register('websocket', Faye.Transport.WebSocket);
|
2494
|
-
|
2495
|
-
if (Faye.Event && Faye.ENV.onbeforeunload !== undefined)
|
2496
|
-
Faye.Event.on(Faye.ENV, 'beforeunload', function() {
|
2497
|
-
Faye.Transport.WebSocket._unloaded = true;
|
2498
|
-
});
|
2499
|
-
|
2500
|
-
Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
|
2501
|
-
initialize: function(dispatcher, endpoint) {
|
2502
|
-
Faye.Transport.prototype.initialize.call(this, dispatcher, endpoint);
|
2503
|
-
if (!Faye.ENV.EventSource) return this.setDeferredStatus('failed');
|
2504
|
-
|
2505
|
-
this._xhr = new Faye.Transport.XHR(dispatcher, endpoint);
|
2506
|
-
|
2507
|
-
endpoint = Faye.copyObject(endpoint);
|
2508
|
-
endpoint.pathname += '/' + dispatcher.clientId;
|
2509
|
-
|
2510
|
-
var socket = new EventSource(Faye.URI.stringify(endpoint)),
|
2511
|
-
self = this;
|
2512
|
-
|
2513
|
-
socket.onopen = function() {
|
2514
|
-
self._everConnected = true;
|
2515
|
-
self.setDeferredStatus('succeeded');
|
2516
|
-
};
|
2517
|
-
|
2518
|
-
socket.onerror = function() {
|
2519
|
-
if (self._everConnected) {
|
2520
|
-
self._handleError([]);
|
2521
|
-
} else {
|
2522
|
-
self.setDeferredStatus('failed');
|
2523
|
-
socket.close();
|
2524
|
-
}
|
2525
|
-
};
|
2526
|
-
|
2527
|
-
socket.onmessage = function(event) {
|
2528
|
-
self._receive(JSON.parse(event.data));
|
2529
|
-
};
|
2530
|
-
|
2531
|
-
this._socket = socket;
|
2532
|
-
},
|
2533
|
-
|
2534
|
-
close: function() {
|
2535
|
-
if (!this._socket) return;
|
2536
|
-
this._socket.onopen = this._socket.onerror = this._socket.onmessage = null;
|
2537
|
-
this._socket.close();
|
2538
|
-
delete this._socket;
|
2539
|
-
},
|
2540
|
-
|
2541
|
-
isUsable: function(callback, context) {
|
2542
|
-
this.callback(function() { callback.call(context, true) });
|
2543
|
-
this.errback(function() { callback.call(context, false) });
|
2544
|
-
},
|
2545
|
-
|
2546
|
-
encode: function(messages) {
|
2547
|
-
return this._xhr.encode(messages);
|
2548
|
-
},
|
2549
|
-
|
2550
|
-
request: function(messages) {
|
2551
|
-
return this._xhr.request(messages);
|
2552
|
-
}
|
2553
|
-
|
2554
|
-
}), {
|
2555
|
-
isUsable: function(dispatcher, endpoint, callback, context) {
|
2556
|
-
var id = dispatcher.clientId;
|
2557
|
-
if (!id) return callback.call(context, false);
|
2558
|
-
|
2559
|
-
Faye.Transport.XHR.isUsable(dispatcher, endpoint, function(usable) {
|
2560
|
-
if (!usable) return callback.call(context, false);
|
2561
|
-
this.create(dispatcher, endpoint).isUsable(callback, context);
|
2562
|
-
}, this);
|
2563
|
-
},
|
2564
|
-
|
2565
|
-
create: function(dispatcher, endpoint) {
|
2566
|
-
var sockets = dispatcher.transports.eventsource = dispatcher.transports.eventsource || {},
|
2567
|
-
id = dispatcher.clientId;
|
2568
|
-
|
2569
|
-
var url = Faye.copyObject(endpoint);
|
2570
|
-
url.pathname += '/' + (id || '');
|
2571
|
-
url = Faye.URI.stringify(url);
|
2572
|
-
|
2573
|
-
sockets[url] = sockets[url] || new this(dispatcher, endpoint);
|
2574
|
-
return sockets[url];
|
2575
|
-
}
|
2576
|
-
});
|
2577
|
-
|
2578
|
-
Faye.extend(Faye.Transport.EventSource.prototype, Faye.Deferrable);
|
2579
|
-
Faye.Transport.register('eventsource', Faye.Transport.EventSource);
|
2580
|
-
|
2581
|
-
Faye.Transport.XHR = Faye.extend(Faye.Class(Faye.Transport, {
|
2582
|
-
encode: function(messages) {
|
2583
|
-
return Faye.toJSON(messages);
|
2584
|
-
},
|
2585
|
-
|
2586
|
-
request: function(messages) {
|
2587
|
-
var href = this.endpoint.href,
|
2588
|
-
xhr = Faye.ENV.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(),
|
2589
|
-
self = this;
|
2590
|
-
|
2591
|
-
xhr.open('POST', href, true);
|
2592
|
-
xhr.setRequestHeader('Content-Type', 'application/json');
|
2593
|
-
xhr.setRequestHeader('Pragma', 'no-cache');
|
2594
|
-
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
2595
|
-
|
2596
|
-
var headers = this._dispatcher.headers;
|
2597
|
-
for (var key in headers) {
|
2598
|
-
if (!headers.hasOwnProperty(key)) continue;
|
2599
|
-
xhr.setRequestHeader(key, headers[key]);
|
2600
|
-
}
|
2601
|
-
|
2602
|
-
var abort = function() { xhr.abort() };
|
2603
|
-
if (Faye.ENV.onbeforeunload !== undefined) Faye.Event.on(Faye.ENV, 'beforeunload', abort);
|
2604
|
-
|
2605
|
-
xhr.onreadystatechange = function() {
|
2606
|
-
if (!xhr || xhr.readyState !== 4) return;
|
2607
|
-
|
2608
|
-
var replies = null,
|
2609
|
-
status = xhr.status,
|
2610
|
-
text = xhr.responseText,
|
2611
|
-
successful = (status >= 200 && status < 300) || status === 304 || status === 1223;
|
2612
|
-
|
2613
|
-
if (Faye.ENV.onbeforeunload !== undefined) Faye.Event.detach(Faye.ENV, 'beforeunload', abort);
|
2614
|
-
xhr.onreadystatechange = function() {};
|
2615
|
-
xhr = null;
|
2616
|
-
|
2617
|
-
if (!successful) return self._handleError(messages);
|
2618
|
-
|
2619
|
-
try {
|
2620
|
-
replies = JSON.parse(text);
|
2621
|
-
} catch (e) {}
|
2622
|
-
|
2623
|
-
if (replies)
|
2624
|
-
self._receive(replies);
|
2625
|
-
else
|
2626
|
-
self._handleError(messages);
|
2627
|
-
};
|
2628
|
-
|
2629
|
-
xhr.send(this.encode(messages));
|
2630
|
-
return xhr;
|
2631
|
-
}
|
2632
|
-
}), {
|
2633
|
-
isUsable: function(dispatcher, endpoint, callback, context) {
|
2634
|
-
callback.call(context, Faye.URI.isSameOrigin(endpoint));
|
2635
|
-
}
|
2636
|
-
});
|
2637
|
-
|
2638
|
-
Faye.Transport.register('long-polling', Faye.Transport.XHR);
|
2639
|
-
|
2640
|
-
Faye.Transport.CORS = Faye.extend(Faye.Class(Faye.Transport, {
|
2641
|
-
encode: function(messages) {
|
2642
|
-
return 'message=' + encodeURIComponent(Faye.toJSON(messages));
|
2643
|
-
},
|
2644
|
-
|
2645
|
-
request: function(messages) {
|
2646
|
-
var xhrClass = Faye.ENV.XDomainRequest ? XDomainRequest : XMLHttpRequest,
|
2647
|
-
xhr = new xhrClass(),
|
2648
|
-
id = ++Faye.Transport.CORS._id,
|
2649
|
-
headers = this._dispatcher.headers,
|
2650
|
-
self = this,
|
2651
|
-
key;
|
2652
|
-
|
2653
|
-
xhr.open('POST', Faye.URI.stringify(this.endpoint), true);
|
2654
|
-
|
2655
|
-
if (xhr.setRequestHeader) {
|
2656
|
-
xhr.setRequestHeader('Pragma', 'no-cache');
|
2657
|
-
for (key in headers) {
|
2658
|
-
if (!headers.hasOwnProperty(key)) continue;
|
2659
|
-
xhr.setRequestHeader(key, headers[key]);
|
2660
|
-
}
|
2661
|
-
}
|
2662
|
-
|
2663
|
-
var cleanUp = function() {
|
2664
|
-
if (!xhr) return false;
|
2665
|
-
Faye.Transport.CORS._pending.remove(id);
|
2666
|
-
xhr.onload = xhr.onerror = xhr.ontimeout = xhr.onprogress = null;
|
2667
|
-
xhr = null;
|
2668
|
-
};
|
2669
|
-
|
2670
|
-
xhr.onload = function() {
|
2671
|
-
var replies = null;
|
2672
|
-
try {
|
2673
|
-
replies = JSON.parse(xhr.responseText);
|
2674
|
-
} catch (e) {}
|
2675
|
-
|
2676
|
-
cleanUp();
|
2677
|
-
|
2678
|
-
if (replies)
|
2679
|
-
self._receive(replies);
|
2680
|
-
else
|
2681
|
-
self._handleError(messages);
|
2682
|
-
};
|
2683
|
-
|
2684
|
-
xhr.onerror = xhr.ontimeout = function() {
|
2685
|
-
cleanUp();
|
2686
|
-
self._handleError(messages);
|
2687
|
-
};
|
2688
|
-
|
2689
|
-
xhr.onprogress = function() {};
|
2690
|
-
|
2691
|
-
if (xhrClass === Faye.ENV.XDomainRequest)
|
2692
|
-
Faye.Transport.CORS._pending.add({id: id, xhr: xhr});
|
2693
|
-
|
2694
|
-
xhr.send(this.encode(messages));
|
2695
|
-
return xhr;
|
2696
|
-
}
|
2697
|
-
}), {
|
2698
|
-
_id: 0,
|
2699
|
-
_pending: new Faye.Set(),
|
2700
|
-
|
2701
|
-
isUsable: function(dispatcher, endpoint, callback, context) {
|
2702
|
-
if (Faye.URI.isSameOrigin(endpoint))
|
2703
|
-
return callback.call(context, false);
|
2704
|
-
|
2705
|
-
if (Faye.ENV.XDomainRequest)
|
2706
|
-
return callback.call(context, endpoint.protocol === Faye.ENV.location.protocol);
|
2707
|
-
|
2708
|
-
if (Faye.ENV.XMLHttpRequest) {
|
2709
|
-
var xhr = new Faye.ENV.XMLHttpRequest();
|
2710
|
-
return callback.call(context, xhr.withCredentials !== undefined);
|
2711
|
-
}
|
2712
|
-
return callback.call(context, false);
|
2713
|
-
}
|
2714
|
-
});
|
2715
|
-
|
2716
|
-
Faye.Transport.register('cross-origin-long-polling', Faye.Transport.CORS);
|
2717
|
-
|
2718
|
-
Faye.Transport.JSONP = Faye.extend(Faye.Class(Faye.Transport, {
|
2719
|
-
encode: function(messages) {
|
2720
|
-
var url = Faye.copyObject(this.endpoint);
|
2721
|
-
url.query.message = Faye.toJSON(messages);
|
2722
|
-
url.query.jsonp = '__jsonp' + Faye.Transport.JSONP._cbCount + '__';
|
2723
|
-
return Faye.URI.stringify(url);
|
2724
|
-
},
|
2725
|
-
|
2726
|
-
request: function(messages) {
|
2727
|
-
var head = document.getElementsByTagName('head')[0],
|
2728
|
-
script = document.createElement('script'),
|
2729
|
-
callbackName = Faye.Transport.JSONP.getCallbackName(),
|
2730
|
-
endpoint = Faye.copyObject(this.endpoint),
|
2731
|
-
self = this;
|
2732
|
-
|
2733
|
-
endpoint.query.message = Faye.toJSON(messages);
|
2734
|
-
endpoint.query.jsonp = callbackName;
|
2735
|
-
|
2736
|
-
var cleanup = function() {
|
2737
|
-
if (!Faye.ENV[callbackName]) return false;
|
2738
|
-
Faye.ENV[callbackName] = undefined;
|
2739
|
-
try { delete Faye.ENV[callbackName] } catch (e) {}
|
2740
|
-
script.parentNode.removeChild(script);
|
2741
|
-
};
|
2742
|
-
|
2743
|
-
Faye.ENV[callbackName] = function(replies) {
|
2744
|
-
cleanup();
|
2745
|
-
self._receive(replies);
|
2746
|
-
};
|
2747
|
-
|
2748
|
-
script.type = 'text/javascript';
|
2749
|
-
script.src = Faye.URI.stringify(endpoint);
|
2750
|
-
head.appendChild(script);
|
2751
|
-
|
2752
|
-
script.onerror = function() {
|
2753
|
-
cleanup();
|
2754
|
-
self._handleError(messages);
|
2755
|
-
};
|
2756
|
-
|
2757
|
-
return {abort: cleanup};
|
2758
|
-
}
|
2759
|
-
}), {
|
2760
|
-
_cbCount: 0,
|
2761
|
-
|
2762
|
-
getCallbackName: function() {
|
2763
|
-
this._cbCount += 1;
|
2764
|
-
return '__jsonp' + this._cbCount + '__';
|
2765
|
-
},
|
2766
|
-
|
2767
|
-
isUsable: function(dispatcher, endpoint, callback, context) {
|
2768
|
-
callback.call(context, true);
|
2769
|
-
}
|
2770
|
-
});
|
2771
|
-
|
2772
|
-
Faye.Transport.register('callback-polling', Faye.Transport.JSONP);
|
2773
|
-
|
2774
|
-
})();
|