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.
35 lines
1016 B
35 lines
1016 B
'use strict';
|
|
|
|
// The simplest and most robust transport, using the well-know cross
|
|
// domain hack - JSONP. This transport is quite inefficient - one
|
|
// message could use up to one http request. But at least it works almost
|
|
// everywhere.
|
|
// Known limitations:
|
|
// o you will get a spinning cursor
|
|
// o for Konqueror a dumb timer is needed to detect errors
|
|
|
|
var inherits = require('inherits')
|
|
, SenderReceiver = require('./lib/sender-receiver')
|
|
, JsonpReceiver = require('./receiver/jsonp')
|
|
, jsonpSender = require('./sender/jsonp')
|
|
;
|
|
|
|
function JsonPTransport(transUrl) {
|
|
if (!JsonPTransport.enabled()) {
|
|
throw new Error('Transport created when disabled');
|
|
}
|
|
SenderReceiver.call(this, transUrl, '/jsonp', jsonpSender, JsonpReceiver);
|
|
}
|
|
|
|
inherits(JsonPTransport, SenderReceiver);
|
|
|
|
JsonPTransport.enabled = function() {
|
|
return !!global.document;
|
|
};
|
|
|
|
JsonPTransport.transportName = 'jsonp-polling';
|
|
JsonPTransport.roundTrips = 1;
|
|
JsonPTransport.needBody = true;
|
|
|
|
module.exports = JsonPTransport;
|