/js/lib/Socket.IO-node/support/socket.io-client/lib/transports/xhr-multipart.js

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs · JavaScript · 37 lines · 22 code · 8 blank · 7 comment · 4 complexity · 10d6cc1c17e5a307b7518a4fa2384a3b MD5 · raw file

  1. /**
  2. * Socket.IO client
  3. *
  4. * @author Guillermo Rauch <guillermo@learnboost.com>
  5. * @license The MIT license.
  6. * @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com>
  7. */
  8. (function(){
  9. var io = this.io;
  10. var XHRMultipart = io.Transport['xhr-multipart'] = function(){
  11. io.Transport.XHR.apply(this, arguments);
  12. };
  13. io.util.inherit(XHRMultipart, io.Transport.XHR);
  14. XHRMultipart.prototype.type = 'xhr-multipart';
  15. XHRMultipart.prototype._get = function(){
  16. var self = this;
  17. this._xhr = this._request('', 'GET', true);
  18. this._xhr.onreadystatechange = function(){
  19. if (self._xhr.readyState == 4) self._onData(self._xhr.responseText);
  20. };
  21. this._xhr.send(null);
  22. };
  23. XHRMultipart.check = function(){
  24. return 'XMLHttpRequest' in window && 'prototype' in XMLHttpRequest && 'multipart' in XMLHttpRequest.prototype;
  25. };
  26. XHRMultipart.xdomainCheck = function(){
  27. return true;
  28. };
  29. })();