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.
32 lines
474 B
32 lines
474 B
4 years ago
|
const XHR = require("./polling");
|
||
|
const JSONP = require("./polling-jsonp");
|
||
|
|
||
|
/**
|
||
|
* Export transports.
|
||
|
*/
|
||
|
|
||
|
module.exports = exports = {
|
||
|
polling: polling,
|
||
|
websocket: require("./websocket")
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Export upgrades map.
|
||
|
*/
|
||
|
|
||
|
exports.polling.upgradesTo = ["websocket"];
|
||
|
|
||
|
/**
|
||
|
* Polling polymorphic constructor.
|
||
|
*
|
||
|
* @api private
|
||
|
*/
|
||
|
|
||
|
function polling(req) {
|
||
|
if ("string" === typeof req._query.j) {
|
||
|
return new JSONP(req);
|
||
|
} else {
|
||
|
return new XHR(req);
|
||
|
}
|
||
|
}
|