You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
509 B

7 years ago
  1. /**
  2. * Module dependencies.
  3. */
  4. var XHR = require('./polling-xhr');
  5. var JSONP = require('./polling-jsonp');
  6. /**
  7. * Export transports.
  8. */
  9. module.exports = exports = {
  10. polling: polling,
  11. websocket: require('./websocket')
  12. };
  13. /**
  14. * Export upgrades map.
  15. */
  16. exports.polling.upgradesTo = ['websocket'];
  17. /**
  18. * Polling polymorphic constructor.
  19. *
  20. * @api private
  21. */
  22. function polling (req) {
  23. if ('string' === typeof req._query.j) {
  24. return new JSONP(req);
  25. } else {
  26. return new XHR(req);
  27. }
  28. }